Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Bruno Piguet
On 11 fév, 22:24, "LL.Snark" wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x1000), "not found") or next((i for i, x in enumerate(t) if x>1000), None) or whatever matches your needs. Note that if you use the second o

Re: Class or Dictionary?

2011-02-11 Thread Martin De Kauwe
Steven, You make some good points and I don't disagree with you. The code is just a transfer from some older c++ code which had all sorts of windows menus etc, which isn't required and would make it impossible to run (again and again). It is not an especially complicated model, and no doubt there

Re: Class or Dictionary?

2011-02-11 Thread Steven D'Aprano
On Fri, 11 Feb 2011 21:47:32 -0800, Dan Stromberg wrote: > Did you have some sort of bad experience with pylint? Do you resent the > 20 minutes it takes to set it up? If you read my post more carefully and less defensively, you'll see that nothing I said was *opposed* to the use of pylint, mere

Re: Class or Dictionary?

2011-02-11 Thread Dan Stromberg
On Fri, Feb 11, 2011 at 4:13 PM, Steven D'Aprano wrote: > On Fri, 11 Feb 2011 10:15:27 -0800, Dan Stromberg wrote: > > >> I'd use a class rather than a dictionary - because with a class, pylint >> (and perhaps PyChecker and pyflakes?) should be able to detect typos >> upfront. > > *Some* typos. Ce

Re: Reassign or discard Popen().stdout from a server process

2011-02-11 Thread John O'Hagan
On Fri, 11 Feb 2011, Nobody wrote: > On Thu, 10 Feb 2011 08:35:24 +, John O'Hagan wrote: > >> > But I'm still a little curious as to why even unsuccessfully > >> > attempting to reassign stdout seems to stop the pipe buffer from > >> > filling up. > >> > >> It doesn't. If the server continues

Re: For loop comprehensions

2011-02-11 Thread Terry Reedy
On 2/11/2011 6:10 PM, Benjamin S Wolf wrote: It occurred to me as I was writing a for loop that I would like to write it in generator comprehension syntax, eg. for a in b if c: Already proposed and rejected. See archives for python-ideas or the gmane.comp.python.ideas mirror. -- Terry Ja

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Terry Reedy
On 2/11/2011 4:24 PM, LL.Snark wrote: Hi, I'm looking for a pythonic way to translate this short Ruby code : t=[6,7,8,6,7,9,8,4,3,6,7] i=t.index {|x| x What does Ruby do if there is no such element? For Python, the answer should be either None or ValueError. If can write it in python several

Re: Writing binary files in windows

2011-02-11 Thread Nick Raptis
On 02/12/2011 05:20 AM, Abhishek Gulyani wrote: When I write binary files in windows: file = open(r'D:\Data.bin','wb') file.write('Random text') file.close() and then open the file it just shows up as normal text. There is nothing binary about it. Why is that? Sorry if this is too much of a

Re: Writing binary files in windows

2011-02-11 Thread Corey Richardson
On 02/11/2011 10:20 PM, Abhishek Gulyani wrote: > When I write binary files in windows: > > file = open(r'D:\Data.bin','wb') > file.write('Random text') > file.close() > > and then open the file it just shows up as normal text. There is nothing > binary about it. Why is that? > > Sorry if this

Writing binary files in windows

2011-02-11 Thread Abhishek Gulyani
When I write binary files in windows: file = open(r'D:\Data.bin','wb') file.write('Random text') file.close() and then open the file it just shows up as normal text. There is nothing binary about it. Why is that? Sorry if this is too much of a noobie question. I tried googling around but couldn

Re: parse html rendered by js

2011-02-11 Thread yanghq
thank u for your reply. yeah, my end goal is something like screen scraping a web site. Duplicating the Javascript behaviour in my Python code will be a huge burden,I'm afraid time can't aford it. someone say that webkit / pamie and other browser engine can render js to html,but pamie is only wo

Re: Problem with giant font sizes in tkinter

2011-02-11 Thread Steven D'Aprano
On Fri, 11 Feb 2011 01:29:02 -0500, Chris Jones wrote: >> >> labelfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*' [...] > First of all, you need to know precisely what the above font name coding > means. [...] > http://www.archive.org/details/xwindowsytemosf03querarch Thanks for the link, th

Re: For loop comprehensions

2011-02-11 Thread Steven D'Aprano
On Fri, 11 Feb 2011 16:59:52 -0700, Ian Kelly wrote: > Why not allow the same thing in for-loop conditions? Because new syntax and new language features means more work. Somebody has to write the code, make sure that it doesn't break existing Python code, test it for bugs, change the document

Re: Class or Dictionary?

2011-02-11 Thread Steven D'Aprano
On Fri, 11 Feb 2011 16:31:09 -0800, Martin De Kauwe wrote: > The 100+ parameters just means "everything" can be adjusted outside of > the code, invariable most of it isn't. If people aren't going to change all these parameters, why are you spending the time and energy writing code for something

Re: Class or Dictionary?

2011-02-11 Thread Martin De Kauwe
On Feb 12, 11:13 am, Steven D'Aprano wrote: > On Fri, 11 Feb 2011 10:15:27 -0800, Dan Stromberg wrote: > > I'd use a class rather than a dictionary - because with a class, pylint > > (and perhaps PyChecker and pyflakes?) should be able to detect typos > > upfront.   > > *Some* typos. Certainly not

Re: Python 32-bit on Windows 64-bit

2011-02-11 Thread MRAB
On 11/02/2011 21:50, Sherm Pendley wrote: "Martin v. Loewis" writes: Am 11.02.2011 19:41, schrieb Craig Yoshida: what kind of memory limitations to processes running on 32-bit python (with 32-bit C extensions like scipy) have on 64-bit Windows? I'm having occasional MemoryErrors when runnin

Re: Class or Dictionary?

2011-02-11 Thread Martin De Kauwe
Sorry I should have added a little more example to help with clarity? So after reading the .INI file I then initialise the objects I described e.g. def initialise_simulation(self): """Set the initial conditions. using values from the .ini value set the C and N pools and other misc st

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread LL.Snark
On 11/02/2011 22:24, LL.Snark wrote: Hi, I'm looking for a pythonic way to translate this short Ruby code : t=[6,7,8,6,7,9,8,4,3,6,7] i=t.index {|x| x=t[0] : i+=1 ... not pythonic I think... Or : t=[6,7,8,6,7,9,8,4,3,6,7] i=[j for j in range(len(t)) if t[j] Thx for your answers. May I add s

Re: Class or Dictionary?

2011-02-11 Thread Steven D'Aprano
On Fri, 11 Feb 2011 10:15:27 -0800, Dan Stromberg wrote: > I'd use a class rather than a dictionary - because with a class, pylint > (and perhaps PyChecker and pyflakes?) should be able to detect typos > upfront. *Some* typos. Certainly not all. The more complex the code -- and with 100 or so

Re: For loop comprehensions

2011-02-11 Thread Ian Kelly
On Fri, Feb 11, 2011 at 4:47 PM, Westley Martínez wrote: > No, too confusing. Then people'll want compound loops e.g.: > > for a in b if c while d else return x: >    print('Ha ha I'm so clever!') I've yet to see anybody arguing for while loops to be nested like that, but we already allow nested

Re: Class or Dictionary?

2011-02-11 Thread Martin De Kauwe
Hi, yes I read a .INI file using ConfigParser, just similar sections (in my opinion) to make one object which i can then pass to different classes. E.G. class Dict2Obj: """ Turn a dictionary into an object. The only purpose of this is that I think it is neater to reference values x.s

Re: For loop comprehensions

2011-02-11 Thread Westley Martínez
On Fri, 2011-02-11 at 15:10 -0800, Benjamin S Wolf wrote: > It occurred to me as I was writing a for loop that I would like to > write it in generator comprehension syntax, eg. > > for a in b if c: > > rather than using one of the more verbose but allowable syntaxes: > > for a in (x for x in

Re: For loop comprehensions

2011-02-11 Thread Jon Clements
On Feb 11, 11:10 pm, Benjamin S Wolf wrote: > It occurred to me as I was writing a for loop that I would like to > write it in generator comprehension syntax, eg. > >   for a in b if c: > > rather than using one of the more verbose but allowable syntaxes: > >   for a in (x for x in b if c): > >  

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Jon Clements
On Feb 11, 9:24 pm, "LL.Snark" wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x > If you don't know Ruby, the second line means : > What is the index, in array t, of the first element x such that x > If can write it

For loop comprehensions

2011-02-11 Thread Benjamin S Wolf
It occurred to me as I was writing a for loop that I would like to write it in generator comprehension syntax, eg. for a in b if c: rather than using one of the more verbose but allowable syntaxes: for a in (x for x in b if c): for a in b: if not c: continue Python 3.1 does not suppo

Re: Asterisk sign before the 'self' keyword

2011-02-11 Thread Steven D'Aprano
On Fri, 11 Feb 2011 07:06:11 -0800, christian.posta wrote: > Within the __call__ function for a class, I saw a method of that class > referred to like this: > > *self.() > > The brackets indicate the method name. What does the *self refer to?? > Does it somehow indicate the scope of the 'self' v

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Paul Rubin
"LL.Snark" writes: > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x=t[0], t).next() Note the above can throw an exception if no suitable element is found. t=[6,7,8,6,7,9,8,4,3,6,7] i=[j for j in range(len(t)) if t[j]http

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Dan Stromberg
On Fri, Feb 11, 2011 at 1:51 PM, Dan Stromberg wrote: > On Fri, Feb 11, 2011 at 1:43 PM, André Roberge > wrote: >> On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: >>> Hi, >>> >>> I'm looking for a pythonic way to translate this short Ruby code : >>> t=[6,7,8,6,7,9,8,4,3,6,7] >>> i

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Josh Benner
On Fri, Feb 11, 2011 at 1:51 PM, Dan Stromberg wrote: > On Fri, Feb 11, 2011 at 1:43 PM, André Roberge > wrote: > > On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: > >> Hi, > >> > >> I'm looking for a pythonic way to translate this short Ruby code : > >> t=[6,7,8,6,7,9,8,4,3,6,7]

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Ian
On Feb 11, 2:24 pm, "LL.Snark" wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| xhttp://mail.python.org/mailman/listinfo/python-list

Re: Python 32-bit on Windows 64-bit

2011-02-11 Thread Sherm Pendley
"Martin v. Loewis" writes: > Am 11.02.2011 19:41, schrieb Craig Yoshida: >> what kind of memory limitations to processes running on 32-bit python >> (with 32-bit C extensions like scipy) have on 64-bit Windows? I'm >> having occasional MemoryErrors when running a python program on >> 64-bit Win

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Dan Stromberg
On Fri, Feb 11, 2011 at 1:43 PM, André Roberge wrote: > On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: >> Hi, >> >> I'm looking for a pythonic way to translate this short Ruby code : >> t=[6,7,8,6,7,9,8,4,3,6,7] >> i=t.index {|x| x> >> If you don't know Ruby, the second line means

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Chris Rebert
On Fri, Feb 11, 2011 at 1:24 PM, LL.Snark wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x > If you don't know Ruby, the second line means : > What is the index, in array t, of the first element x such that x > If ca

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread André Roberge
On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x > If you don't know Ruby, the second line means : > What is the index, in array t, of the first element x such

Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread LL.Snark
Hi, I'm looking for a pythonic way to translate this short Ruby code : t=[6,7,8,6,7,9,8,4,3,6,7] i=t.index {|x| x=t[0] : i+=1 ... not pythonic I think... Or : t=[6,7,8,6,7,9,8,4,3,6,7] i=[j for j in range(len(t)) if t[j]http://mail.python.org/mailman/listinfo/python-list

Re: Python 32-bit on Windows 64-bit

2011-02-11 Thread Martin v. Loewis
Am 11.02.2011 19:41, schrieb Craig Yoshida: > what kind of memory limitations to processes running on 32-bit python > (with 32-bit C extensions like scipy) have on 64-bit Windows? I'm > having occasional MemoryErrors when running a python program on > 64-bit Windows 7 that runs fine on my OS X ma

Another related OO Python ?

2011-02-11 Thread Doug Epling
hey, does anyone find the UML useful during Python development of larger projects? -- http://mail.python.org/mailman/listinfo/python-list

Re: Class or Dictionary?

2011-02-11 Thread Jean-Michel Pichavant
Martin De Kauwe wrote: Hi, I have a series of parameter values which i need to pass throughout my code (>100), in C I would use a structure for example. However in python it is not clear to me if it would be better to use a dictionary or build a class object? Personally I think accessing the val

Re: Class or Dictionary?

2011-02-11 Thread Andrea Crotti
Il giorno 11/feb/2011, alle ore 19.47, Ethan Furman ha scritto: > > I strongly disagree. Code readability is one of the most important issues. Perfectly agree with that, but obj.name = x obj.surname = y obj['name'] = x obj['surname'] = y are both quite readable in my opinion. Other things a

Re: Asterisk sign before the 'self' keyword

2011-02-11 Thread Ulrich Eckhardt
Hmmm. Is it just us that read this topic and think of an object with a psychic disorder like multiple personalities? :): TGIF. Uli -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 32-bit on Windows 64-bit

2011-02-11 Thread Michel Claveau - MVP
Hi! Python 32 bits (& Pywin32) limits are: 2 GB on win.7_32 bits 4 GB on win.7_64 bits That's what I found in my tests. @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Executing functions

2011-02-11 Thread DataSmash
Appreciate the responses, guys. I now see the difference between the ways I was trying to call function(s). R.D. -- http://mail.python.org/mailman/listinfo/python-list

Re: OO Python

2011-02-11 Thread Paul Symonds
Thank you -- http://mail.python.org/mailman/listinfo/python-list

Re: Class or Dictionary?

2011-02-11 Thread Miki Tebeka
> I have a series of parameter values which i need to pass throughout my > code (>100), in C I would use a structure for example. However in > python it is not clear to me if it would be better to use a dictionary > or build a class object? namedtuple can be a quick and easy solution for you. http:

Re: Class or Dictionary?

2011-02-11 Thread Bill Felton
>From an old-time Smalltalker / object guy, take this for whatever it's worth. The *primary* reason for going with a class over a dictionary is if there is specific behavior that goes along with these attributes. If there isn't, if this is "just" an 'object store', there's no reason not to use a

Python 32-bit on Windows 64-bit

2011-02-11 Thread Craig Yoshida
what kind of memory limitations to processes running on 32-bit python (with 32-bit C extensions like scipy) have on 64-bit Windows? I'm having occasional MemoryErrors when running a python program on 64-bit Windows 7 that runs fine on my OS X machine. Both machines are using a 64-bit OS and h

Re: Class or Dictionary?

2011-02-11 Thread Ethan Furman
Andrea Crotti wrote: On Feb 11, 3:56 pm, Martin De Kauwe wrote: Hi, I have a series of parameter values which i need to pass throughout my code (>100), in C I would use a structure for example. However in python it is not clear to me if it would be better to use a dictionary or build a class o

Re: Reassign or discard Popen().stdout from a server process

2011-02-11 Thread Nobody
On Thu, 10 Feb 2011 08:35:24 +, John O'Hagan wrote: >> > But I'm still a little curious as to why even unsuccessfully attempting >> > to reassign stdout seems to stop the pipe buffer from filling up. >> >> It doesn't. If the server continues to run, then it's ignoring/handling >> both SIGPIPE

Re: Class or Dictionary?

2011-02-11 Thread Terry Reedy
or Module;-? On 2/11/2011 9:56 AM, Martin De Kauwe wrote: Hi, I have a series of parameter values which i need to pass throughout my code (>100), in C I would use a structure for example. However in python it is not clear to me if it would be better to use a dictionary or build a class object?

Re: Class or Dictionary?

2011-02-11 Thread Andrea Crotti
Il giorno 11/feb/2011, alle ore 17.01, Martin De Kauwe ha scritto: > > i have a number some are smaller, for example switch/control flags. > But the rest can be quite large. I can split them but I don't see the > advantage particularly. Currently by using them (e.g. > params.rate_of_decomp) it cl

Re: Shared memory python between two separate shell-launched processes

2011-02-11 Thread Miki Tebeka
> So speed up the compile-test cycle I'm thinking about running a > completely separate process (not a fork, but a processed launched form > a different terminal) that can load the cache once then dunk it in an > area of shareed memory.Each time I debug the main program, it can > start up quick

Re: Class or Dictionary?

2011-02-11 Thread Dan Stromberg
On Fri, Feb 11, 2011 at 6:56 AM, Martin De Kauwe wrote: > Hi, > > I have a series of parameter values which i need to pass throughout my > code (>100), in C I would use a structure for example. However in > python it is not clear to me if it would be better to use a dictionary > or build a class o

Re: Which non SQL Database ?

2011-02-11 Thread Doug Epling
On 12/4/2010 5:42 PM, Jorge Biquez wrote: Hello all. Newbie question. Sorry. As part of my process to learn python I am working on two personal applications. Both will do it fine with a simple structure of data stored in files. I now there are lot of databases around I can use but I would like

Re: Asterisk sign before the 'self' keyword

2011-02-11 Thread christian.posta
On Feb 11, 9:57 am, "christian.posta" wrote: > On Feb 11, 9:10 am, Robert Kern wrote: > > > > > On 2/11/11 9:06 AM, christian.posta wrote: > > > > I searched quickly to see whether this may have been discussed before, > > > but it's possible my search criteria was not refined enough to get any >

Re: Asterisk sign before the 'self' keyword

2011-02-11 Thread christian.posta
On Feb 11, 9:10 am, Robert Kern wrote: > On 2/11/11 9:06 AM, christian.posta wrote: > > > > > I searched quickly to see whether this may have been discussed before, > > but it's possible my search criteria was not refined enough to get any > > hits. Forgive me if this is a silly question.. > > > I

Re: Asterisk sign before the 'self' keyword

2011-02-11 Thread christian.posta
On Feb 11, 9:10 am, Robert Kern wrote: > On 2/11/11 9:06 AM, christian.posta wrote: > > > > > I searched quickly to see whether this may have been discussed before, > > but it's possible my search criteria was not refined enough to get any > > hits. Forgive me if this is a silly question.. > > > I

Re: Asterisk sign before the 'self' keyword

2011-02-11 Thread christian.posta
On Feb 11, 9:10 am, Robert Kern wrote: > On 2/11/11 9:06 AM, christian.posta wrote: > > > > > I searched quickly to see whether this may have been discussed before, > > but it's possible my search criteria was not refined enough to get any > > hits. Forgive me if this is a silly question.. > > > I

Re: Which non SQL Database ?

2011-02-11 Thread Aahz
In article <4d3c8d53$0$44021$742ec...@news.sonic.net>, John Nagle wrote: > > Google's BigTable and Facebook's Cassandra offer impressive >performance at very large scale. But they're way overkill for >a desktop app. Even the midrange systems, like CouchDB, are >far too much machinery for a

Re: Shared memory python between two separate shell-launched processes

2011-02-11 Thread Philip
On Feb 11, 6:27 am, Adam Skutt wrote: > On Feb 10, 9:30 am, "Charles Fox (Sheffield)" > wrote: > > > But when I look at posix_ipc and POSH it looks like you have to fork > > the second process from the first one, rather than access the shared > > memory though a key ID as in standard C unix share

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-11 Thread Xah Lee
On Feb 11, 2:06 am, Alexander Gattin wrote: > Hello, > > On Tue, Feb 08, 2011 at 05:32:05PM +, Icarus > > Sparry wrote: > > The key thing which makes this 'modern' is the > > '+' at the end of the command, rather than '\;'. > > This causes find to execute the grep once per > > group of files,

Re: Asterisk sign before the 'self' keyword

2011-02-11 Thread Robert Kern
On 2/11/11 9:06 AM, christian.posta wrote: I searched quickly to see whether this may have been discussed before, but it's possible my search criteria was not refined enough to get any hits. Forgive me if this is a silly question.. I was reading some Python code from a third-party app for the dj

TestFixtures 1.9.0 Released!

2011-02-11 Thread Chris Withers
Hi All, I'm happy to announce a new release of TestFixtures. This release adds a helper for tests of code using zope.component: http://packages.python.org/testfixtures/components.html The package is on PyPI and a full list of all the links to docs, issue trackers and the like can be found her

Re: Class or Dictionary?

2011-02-11 Thread Martin De Kauwe
On Feb 12, 2:40 am, Andrea Crotti wrote: > On Feb 11, 3:56 pm, Martin De Kauwe wrote: > > > Hi, > > > I have a series of parameter values which i need to pass throughout my > > code (>100), in C I would use a structure for example. However in > > python it is not clear to me if it would be better

Re: Asterisk sign before the 'self' keyword

2011-02-11 Thread Ian Kelly
On 2/11/2011 8:06 AM, christian.posta wrote: I searched quickly to see whether this may have been discussed before, but it's possible my search criteria was not refined enough to get any hits. Forgive me if this is a silly question.. I was reading some Python code from a third-party app for the

Re: Class or Dictionary?

2011-02-11 Thread Andrea Crotti
On Feb 11, 3:56 pm, Martin De Kauwe wrote: > Hi, > > I have a series of parameter values which i need to pass throughout my > code (>100), in C I would use a structure for example. However in > python it is not clear to me if it would be better to use a dictionary > or build a class object? Person

Asterisk sign before the 'self' keyword

2011-02-11 Thread christian.posta
I searched quickly to see whether this may have been discussed before, but it's possible my search criteria was not refined enough to get any hits. Forgive me if this is a silly question.. I was reading some Python code from a third-party app for the django project... i saw this in the code and I

Class or Dictionary?

2011-02-11 Thread Martin De Kauwe
Hi, I have a series of parameter values which i need to pass throughout my code (>100), in C I would use a structure for example. However in python it is not clear to me if it would be better to use a dictionary or build a class object? Personally I think accessing the values is neater (visually)

Re: returning all matching groups with re.search()

2011-02-11 Thread MRAB
On 11/02/2011 04:34, Roland Mueller wrote: Hello, On 02/07/2011 06:26 PM, Mauro Caceres wrote: >>> import re >>> help(re.findall) Help on function findall in module re: findall(pattern, string, flags=0) Return a list of all non-overlapping matches in the string. If one or more groups are prese

Re: Executing functions

2011-02-11 Thread Ethan Furman
DataSmash wrote: Can someone help me understand why Example #1 & Example #2 will run the functions, while Example #3 DOES NOT? Thanks for your time! R.D. def One(): print "running fuction 1" def Two(): print "running fuction 2" def Three(): print "running fuction 3" # Example #1 fL

Re: Parameterized functions of no arguments?

2011-02-11 Thread Hrvoje Niksic
Chris Rebert writes: > It's a well-known problem due to the intricacies of Python's scoping > rules. Actually, it is not specific to Python's scoping rules (which mandate local, then module-level, then built-in name lookup). The root of the surprise is, as you correctly point out, the fact that

RE: Executing functions

2011-02-11 Thread Andreas Tawn
> Can someone help me understand why Example #1 & Example #2 will run > the functions, > while Example #3 DOES NOT? > Thanks for your time! > R.D. > > def One(): > print "running fuction 1" > def Two(): > print "running fuction 2" > def Three(): > print "running fuction 3" > > > # Ex

Re: Executing functions

2011-02-11 Thread nn
On Feb 11, 9:15 am, DataSmash wrote: > Can someone help me understand why Example #1 & Example #2 will run > the functions, > while Example #3 DOES NOT? > Thanks for your time! > R.D. > > def One(): >     print "running fuction 1" > def Two(): >     print "running fuction 2" > def Three(): >     p

Executing functions

2011-02-11 Thread DataSmash
Can someone help me understand why Example #1 & Example #2 will run the functions, while Example #3 DOES NOT? Thanks for your time! R.D. def One(): print "running fuction 1" def Two(): print "running fuction 2" def Three(): print "running fuction 3" # Example #1 fList = ["Two()","Thr

Re: wx.Frame hidden, and customising the close button

2011-02-11 Thread Mark Carter
On Feb 11, 1:39 pm, Vlastimil Brom wrote: > (wxPython-specific questions may be rather discussed  on that > maillist:http://groups.google.com/group/wxpython-users/topics?pli=1 Just the ticket! Many thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: wx.Frame hidden, and customising the close button

2011-02-11 Thread Vlastimil Brom
2011/2/11 Mark Carter : > Is there a way of testing whether a frame (suppose I have it as a > variable my_frame) is hidden in wxPython? > > Also, is there a way that I can over-ride the close button so that the > frame becomes hidden rather than destroyed, and perform supplementary > tests? > -- >

Re: Problem with giant font sizes in tkinter

2011-02-11 Thread Arndt Roger Schneider
Steven D'Aprano schrieb: On Thu, 10 Feb 2011 15:48:47 +, Cousin Stanley wrote: Steven D'Aprano wrote: I have a tkinter application under Python 2.6 which is shows text in a giant font, about twenty(?) times larger than expected. The fonts are set using: titlefont = '-Adobe-Helvetica-B

Re: Shared memory python between two separate shell-launched processes

2011-02-11 Thread Jean-Paul Calderone
On Feb 11, 5:52 am, "Charles Fox (Sheffield)" wrote: > On Feb 10, 6:22 pm, Jean-Paul Calderone > wrote: > > > > > > > > > > > On Feb 10, 12:21 pm, "Charles Fox (Sheffield)" > > wrote: > > > > On Feb 10, 3:43 pm, Jean-Paul Calderone > > > wrote: > > > > > On Feb 10, 9:30 am, "Charles Fox (Sheffi

wx.Frame hidden, and customising the close button

2011-02-11 Thread Mark Carter
Is there a way of testing whether a frame (suppose I have it as a variable my_frame) is hidden in wxPython? Also, is there a way that I can over-ride the close button so that the frame becomes hidden rather than destroyed, and perform supplementary tests? -- http://mail.python.org/mailman/listinf

Re: Remove whitespaces and line breaks in a XML file

2011-02-11 Thread Sven
On 2011-02-07 18:46:17 -0500, Josh English said: I found the code posted at http://infix.se/2007/02/06/gentlemen-indent-your-xml quite helpful in turning my xml into human-readable structures. It works best for XML-Data. lxml, which the code is using, already has a pretty_print feature acc

Re: Shared memory python between two separate shell-launched processes

2011-02-11 Thread Adam Skutt
On Feb 10, 9:30 am, "Charles Fox (Sheffield)" wrote: > > But when I look at posix_ipc and POSH it looks like you have to fork > the second process from the first one, rather than access the shared > memory though a key ID as in standard C unix shared memory.  Am I > missing something?   Are there

Re: Shared memory python between two separate shell-launched processes

2011-02-11 Thread Charles Fox (Sheffield)
On Feb 10, 6:22 pm, Jean-Paul Calderone wrote: > On Feb 10, 12:21 pm, "Charles Fox (Sheffield)" > wrote: > > > > > On Feb 10, 3:43 pm, Jean-Paul Calderone > > wrote: > > > > On Feb 10, 9:30 am, "Charles Fox (Sheffield)" > > > wrote: > > > > > Hi guys, > > > > I'm working on debugging a large py

Re: Parameterized functions of no arguments?

2011-02-11 Thread Rotwang
On 11/02/2011 08:19, Steven D'Aprano wrote: [...] Re-writing them as normal function defs may help. I'm going to do them in reverse order: # lambda: f(k) def func(): return f(k) When you call func() with no arguments, the body is executed and f(k) is returned. Where do f and k come from?

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-11 Thread Alexander Gattin
Hello, On Tue, Feb 08, 2011 at 05:32:05PM +, Icarus Sparry wrote: > The key thing which makes this 'modern' is the > '+' at the end of the command, rather than '\;'. > This causes find to execute the grep once per > group of files, rather than once per file. many thanks to you, man! I'm surp

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-11 Thread Alexander Gattin
Hello, On Thu, Feb 10, 2011 at 07:52:34AM +0100, Petter Gustad wrote: > r...@rpw3.org (Rob Warnock) writes: > > invocation was given only one arg!! IT FOUND > > THE PATTERN, BUT DIDN'T TELL ME WHAT > > !@^%!$@#@! FILE IT WAS IN!! :-{ > > Sounds frustrating, but grep -H will always > print the fi

Re: Parameterized functions of no arguments?

2011-02-11 Thread Ben Finney
Rotwang writes: > On 11/02/2011 05:42, Ben Finney wrote: > > What part is inelegant to your eye? > > I guess the fact that it exploits the way Python evaluates default > function arguments to achieve something other than what they were > intended for. I see. If that seems like an exploit, I can

Re: Easy function, please help.

2011-02-11 Thread Stephen Hansen
On 2/10/11 7:34 PM, alex23 wrote: > rantingrick wrote: >> 1. When has 2 bytecode instructions EVER out weighed a solid >> readability feature's incorporation into Python? > > The original point was whether or not the code is identical, which > Terry showed it was not. Rick does not understand wh

Re: Problem with giant font sizes in tkinter

2011-02-11 Thread Stephen Hansen
On 2/10/11 7:15 PM, rantingrick wrote: > I am *seriously* ...blah You are a child. This is your second pointless response to this thread. Part of me wants to say, stop behaving like a 13 year old; only you're behaving worse then several 13 year olds I know. It would be an insult to their maturit

parse html rendered by js

2011-02-11 Thread yanghq
hi, I wanna get attribute value like href,src... in html. for simple html page libxml2dom can help me parse it into dom, and get what I want; but for some pages rendered by js, like: document.write( ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ '' ) how can I get the atrribute v

Re: [ANN] Pyro 3.11 released

2011-02-11 Thread yanghq
hi, I wanna get attribute value like href,src... in html. for simple html page libxml2dom can help me parse it into dom, and get what I want; but for some pages rendered by js, like: document.write( ''+ ''+ ''+ ''+ ''

Re: Parameterized functions of no arguments?

2011-02-11 Thread Steven D'Aprano
On Fri, 11 Feb 2011 06:32:56 +, Rotwang wrote: > I don't understand why this works. What is the difference between > > (lambda x: lambda: f(x))(k) > > and > > lambda: f(k) > > ? Re-writing them as normal function defs may help. I'm going to do them in reverse order: # lambda:

Re: Parameterized functions of no arguments?

2011-02-11 Thread Paul Rubin
Dennis Lee Bieber writes: >> menu.add_command(label = str(k), command = lambda: f(k)) > I'm not sure, but what effect does > menu.add_command(label=str(k), command = lambda k=k: f(k)) > have on the processing. In the first example, k is a free variable in the lambda,