Re: object query assigned variable name?

2009-05-05 Thread John O'Hagan
On Tue, 5 May 2009, Sion Arrowsmith wrote: > John O'Hagan wrote: > >I can see that it's tantalizing, though, because _somebody_ must know > > about the assignment; after all, we just executed it! > > Except we haven't, if we're talking about reporting from the > > object's __init__: > >>> class B

Re: problem in using sendmail in multi thread

2009-05-05 Thread gganesh
On May 5, 9:25 pm, Piet van Oostrum wrote: > > gganesh (g) wrote: > >g> hi, > >g> I'm a beginner in using Python script > >g> I'm trying to send mails using multi-thread > >g> I wrote > >g> FROM = 'ganeshx...@.com' > >g> # for more mail add';' the another mail id > >g> listTo = ['g@gm

Re: Cannot start a thread in atexit callback

2009-05-05 Thread Gabriel Genellina
En Tue, 05 May 2009 23:52:25 -0300, Zac Burns escribió: It seems that one cannot start a thread in an atexit callback. My use case is that I have a IO heavy callback that I want to run in a thread so that other callbacks can finish while it's doing it's thing to save on exit time. Try creati

Re: pyc files problem

2009-05-05 Thread Gabriel Genellina
En Wed, 06 May 2009 00:43:25 -0300, Mohamed Lrhazi escribió: My code sends a pointer to a Python function to a C library, using ctypes module. When my program restarts, after a crash or normal exit... it cannot start again without sigfaulting Do you mean that, if you delete the .pyc files y

Re: list comprehension question

2009-05-05 Thread Terry Reedy
Steven D'Aprano wrote: On Tue, 05 May 2009 13:43:32 -0400, J. Cliff Dyer wrote: Except for the ones that it doesn't cover, like strings: hasattr('abcd', '__iter__') False True in Python3 -- http://mail.python.org/mailman/listinfo/python-list

Re: Code works fine except...

2009-05-05 Thread John Yeung
On May 5, 11:37 pm, Ross wrote: > On May 5, 10:33 am, MRAB wrote: > > > Here's my approach (incomplete): > > FYI... I was testing your code further and discovered a strange > outcome... when there are 16 people for 7 courts, every 7th > round your code produces 4 byes instead of the correct 2 by

Re: pyc files problem

2009-05-05 Thread Steven D'Aprano
On Tue, 05 May 2009 23:43:25 -0400, Mohamed Lrhazi wrote: > Hello, > > My code sends a pointer to a Python function to a C library, using > ctypes module. When my program restarts, after a crash or normal exit... > it cannot start again without sigfaulting > > What is the proper way around this

Re: list comprehension question

2009-05-05 Thread Steven D'Aprano
On Tue, 05 May 2009 20:36:37 -0700, alex23 wrote: > On May 6, 4:01 am, "J. Cliff Dyer" wrote: >> The way you have to bounce your eyes back and forth in the >> comprehension makes it hard to read the logic.  With the loop, on the >> other hand it is blatantly obvious which way the nesting occurs.

Re: Self function

2009-05-05 Thread Gabriel Genellina
En Tue, 05 May 2009 22:35:08 -0300, Rhodri James escribió: On Tue, 05 May 2009 21:43:16 +0100, wrote: wolfram.hinde...: It is easy to change all references of the function name, except for those in the function body itself? That needs some explantation. I can answer this. If I have a rec

pyc files problem

2009-05-05 Thread Mohamed Lrhazi
Hello, My code sends a pointer to a Python function to a C library, using ctypes module. When my program restarts, after a crash or normal exit... it cannot start again without sigfaulting What is the proper way around this problem? other than adding code to delete the cache files? Thanks a lot,

Re: Code works fine except...

2009-05-05 Thread Ross
On May 5, 10:33 am, MRAB wrote: > Ross wrote: > > On May 5, 12:32 am, John Yeung wrote: > >> On May 5, 1:12 am, John Yeung wrote: > > >>> [...] the problem may require bigger guns (either much better > >>> math or much more sophisticated programming). > >> Yes, I'm responding to myself. > > >> W

Re: list comprehension question

2009-05-05 Thread alex23
On May 6, 4:01 am, "J. Cliff Dyer" wrote: > The way you have to bounce your eyes back and forth in the comprehension > makes it hard to read the logic.  With the loop, on the other hand it is > blatantly obvious which way the nesting occurs. > > [ item for j in a if len(j)==2 for item in j i

Re: yet another list comprehension question

2009-05-05 Thread namekuseijin
2009/5/5 Ricardo Aráoz : > This seems to work for any length tuples : > a = [(1,2), (3,4, 'goes'), (5,None), (6,7, 8, 'as', None), (8, None), (9, 0)] [tup for tup in a if not [e for e in tup if e == None]] > [(1, 2), (3, 4, 'goes'), (9, 0)] Why that extra "for"? KISS >>> a = [(1,2

FLV download script works, but I want to enhance it

2009-05-05 Thread The Music Guy
I've written a script that can scan any number of web pages for urls to .flv (Flash Video) files and then download them using urllib2. It's kind of like a YouTube download utility, but more general-purpose (and it doesn't actually work with YouTube. :P). The script works fine; it even has support f

Re: call function of class instance with no assigned name?

2009-05-05 Thread Dave Angel
George Oliver wrote: On May 5, 11:59 am, Dave Angel wrote: 1) forget about getattr() unless you have hundreds of methods in your map. The real question is why you need two maps. What good is the "command string" doing you? Why not just map the keyvalues directly into function objects?

Cannot start a thread in atexit callback

2009-05-05 Thread Zac Burns
It seems that one cannot start a thread in an atexit callback. My use case is that I have a IO heavy callback that I want to run in a thread so that other callbacks can finish while it's doing it's thing to save on exit time. Example code (py3k) import

Re: Problem with case insensitive volumes

2009-05-05 Thread Gabriel Genellina
En Tue, 05 May 2009 12:55:13 -0300, spillz escribió: /my/path/to/usbkey/and/file everything up to "/my/path/to/usbkey" is case sensitive. only the "and/ file" is case insensitive. but my list of stored paths might include all images under "/my". thus /my/path/to/usbkey/and/file1==/my/path/to/

Re: list comprehension question

2009-05-05 Thread Steven D'Aprano
On Tue, 05 May 2009 13:43:32 -0400, J. Cliff Dyer wrote: > On Fri, 2009-05-01 at 13:00 -0400, John Posner wrote: >> Shane Geiger wrote: >> >if type(el) == list or type(el) is tuple: >> A tiny improvement: >> >> if type(el) in (list, tuple): >> >> > Another alternative, which might b

work at online earn 50$ daily

2009-05-05 Thread revathy
click the following link == http://www.s1.webstarts.com/physicsengines/ === -- http://mail.python.org/mailman/listinfo/python-list

Re: Self function

2009-05-05 Thread Rhodri James
On Tue, 05 May 2009 21:43:16 +0100, wrote: wolfram.hinde...: It is easy to change all references of the function name, except for those in the function body itself? That needs some explantation. I can answer this. If I have a recursive function, I may want to create a similar function, so I

Re: Self function

2009-05-05 Thread Steven D'Aprano
On Tue, 05 May 2009 06:30:01 -0700, Arnaud Delobelle wrote: > One issue with automatically binding a local variable to the current > function is with nested functions: > > def foo() > def bar(): ># How do I call foo() from here? As foo(), just like you would call foo() from outside o

Install Python 3.0 dmg to macos 10.5

2009-05-05 Thread silverburgh
Hi, If I install python 3.0 dmg, will it wipe out the existing python installation on macos 10.5 (i don't know how the original python was installed ( i think it is version 2.5). Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: Numpy on python 2.7a

2009-05-05 Thread David Cournapeau
On Wed, May 6, 2009 at 4:06 AM, A. Cavallo wrote: > Hi, > > I'm trying to compile numpy using my own pet project based on the python svn > code (that's the reason for the 2.7a tag). It is a python bug, see bugs 5940 and 5941. cheers, David -- http://mail.python.org/mailman/listinfo/python-list

Re: call function of class instance with no assigned name?

2009-05-05 Thread Rhodri James
On Tue, 05 May 2009 16:52:39 +0100, George Oliver wrote: hi, I'm a Python beginner with a basic question. I'm writing a game where I have keyboard input handling defined in one class, and command execution defined in another class. The keyboard handler class contains a dictionary that maps a

Re: Any idea to emulate tail -f

2009-05-05 Thread norseman
Joel Juvenal Rivera Rivera wrote: I want to make something very similar to the command tail -f (follow a file), i have been trying with some while True and some microsleeps (about .1 s); did someone has already done something like this? And about the file is the apache acceslog of a site with

Re: yet another list comprehension question

2009-05-05 Thread Ricardo Aráoz
namekuseijin wrote: > On May 4, 9:15 am, David Robinow wrote: > >> On Mon, May 4, 2009 at 2:33 AM, namekuseijin >> >> wrote: >> >> ls = [(1,2), (3,4), (5, None), (6,7), (8, None)] >> [(x,y) for (x,y) in ls if y] >> >>> [(1, 2), (3, 4), (6, 7)] >>> >> Nope.

Re: Self function

2009-05-05 Thread MRAB
Steve Howell wrote: On May 4, 11:08 pm, Steven D'Aprano wrote: I propose a small piece of sugar. When a function is entered, Python creates an ordinary local name in the function's local namespace, and binds the function itself to that name. Two possibilities for the name are `this` or `__this_

Re: Error in running python -v on Mac ox 10.5.

2009-05-05 Thread Diez B. Roggisch
silverburgh schrieb: Hi, I run 'python -v' on Macos 10.5 but I get this error : # can't create /System/Library/Frameworks/Python.framework/Versions/ 2.5/lib/python2.5/encodings/utf_8.pyc Can you please tell me how to fix it? This looks like a rights-problem to me, and a missing pyc-file. If

Re: call function of class instance with no assigned name?

2009-05-05 Thread George Oliver
Thanks for the suggestions so far. I've taken the advice to keep things simple so currently I'm just creating one instance of the commandHandler and assigning it a name with command = commandHandler (). This makes it easy to call it from any of the other handlers, and I think this will work for wha

Google selects Mercurial for DVCS support

2009-05-05 Thread Terry Reedy
Given the debate over Python's choice of Mercurial, some might fine the following interesting. http://google-code-updates.blogspot.com/2009/04/mercurial-support-for-project-hosting.html Currently, Mercurial support will be in addition to continued Subversion support. It was also reported on ht

Re: How to walk up parent directories?

2009-05-05 Thread Gunter Henriksen
Be careful not to presume "/a/b/" is the same directory as "/a/b/c/../" I would consider the latter the parent of /a/b/c/, not the former. -- http://mail.python.org/mailman/listinfo/python-list

Re: what's the best way to call a method of object without a guarantee of its existence

2009-05-05 Thread Leon
On May 5, 3:25 am, Marco Mariani wrote: > Leon wrote: > > One way,  define the object before it is used, > > like this: > > object = None > > This is a good practice anyway. Conditional existance of objects is > quite evil. Resorting to if defined('foo') is double-plus-ugly. This was why I asked

Re: Numpy on python 2.7a

2009-05-05 Thread Robert Kern
On 2009-05-05 15:06, A. Cavallo wrote: Hi, I'm trying to compile numpy using my own pet project based on the python svn code (that's the reason for the 2.7a tag). Ask on the numpy-discussion mailing list: http://www.scipy.org/Mailing_Lists -- Robert Kern "I have come to believe that the w

Re: Self function

2009-05-05 Thread Aaron Brady
On May 5, 3:54 pm, bearophileh...@lycos.com wrote: > Aaron Brady: > > > >>> def auto( f ): > > > ...     def _inner( *ar, **kw ): > > ...             return f( g, *ar, **kw ) > > ...     g= _inner > > ...     return g > > Looks nice, I'll try to the following variant to see if it's usable: > > def

Re: Error in running python -v on Mac ox 10.5.

2009-05-05 Thread Piet van Oostrum
> silverburgh (s) wrote: >s> Hi, >s> I run 'python -v' on Macos 10.5 but I get this error : >s> # can't create /System/Library/Frameworks/Python.framework/Versions/ >s> 2.5/lib/python2.5/encodings/utf_8.pyc >s> Can you please tell me how to fix it? This looks like the utf_8.py file has not

Re: Self function

2009-05-05 Thread bearophileHUGS
Aaron Brady: > >>> def auto( f ): > > ...     def _inner( *ar, **kw ): > ...             return f( g, *ar, **kw ) > ...     g= _inner > ...     return g Looks nice, I'll try to the following variant to see if it's usable: def thisfunc(fun): """Decorator to inject a default name of a funct

Re: Self function

2009-05-05 Thread bearophileHUGS
wolfram.hinde...: > It is easy to change all references of the function name, except for > those in the function body itself? That needs some explantation. I can answer this. If I have a recursive function, I may want to create a similar function, so I copy and paste it, to later modify the copied

Re: python docs for beginner programmer?

2009-05-05 Thread Deep_Feelings
that is good ,thank you anyone did that ? learning from python docs straight away ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Code works fine except...

2009-05-05 Thread Ross
On May 5, 1:33 pm, MRAB wrote: > Ross wrote: > > On May 5, 12:32 am, John Yeung wrote: > >> On May 5, 1:12 am, John Yeung wrote: > > >>> [...] the problem may require bigger guns (either much better > >>> math or much more sophisticated programming). > >> Yes, I'm responding to myself. > > >> We

Re: Self function

2009-05-05 Thread Duncan Booth
Aaron Brady wrote: > Here is how to get the function into the function as an argument, and > still permit recursive calls onto it. > def auto( f ): > ... def _inner( *ar, **kw ): > ... return f( g, *ar, **kw ) > ... g= _inner > ... return g > ... @auto > ... def

Re: call function of class instance with no assigned name?

2009-05-05 Thread Aaron Brady
On May 5, 2:17 pm, George Oliver wrote: > On May 5, 11:59 am, Dave Angel wrote: > > > 1) forget about getattr() unless you have hundreds of methods in your > > map.  The real question is why you need two maps. What good is the > > "command string" doing you?   Why not just map the keyvalues direc

Re: AutoComplete in C++ Editor for Python

2009-05-05 Thread justme
I the rope project http://rope.sourceforge.net/ has an autocomplete lib. (I have not used it just remember reading about it) -- http://mail.python.org/mailman/listinfo/python-list

Re: Self function

2009-05-05 Thread Aaron Brady
On May 5, 2:50 pm, Steve Howell wrote: > On May 4, 11:08 pm, Steven D'Aprano > > wrote: > > > I propose a small piece of sugar. When a function is entered, Python > > creates an ordinary local name in the function's local namespace, and > > binds the function itself to that name. Two possibilitie

Re: Self function

2009-05-05 Thread Steve Howell
On May 4, 11:08 pm, Steven D'Aprano wrote: > > I propose a small piece of sugar. When a function is entered, Python > creates an ordinary local name in the function's local namespace, and > binds the function itself to that name. Two possibilities for the name > are `this` or `__this__`, analogous

Re: Way to use proxies & login to site?

2009-05-05 Thread Kushal Kumaran
On Wed, Apr 29, 2009 at 8:21 AM, inVINCable wrote: > On Apr 27, 7:40 pm, inVINCable wrote: >> Hello, >> >> I have been using ClientForm to log in to sites & ClientCookie so I >> can automatically log into my site to do some penetration testing, >> although, I cannot figure out a solution to use p

Re: SQL and CSV

2009-05-05 Thread Tim Golden
Nick wrote: Part of the problem is that the 'selection' needs to be in a config file. I can put the if row['status'] != 'Cancelled': return True into a config, read it and eval it, but its not quite as clean as an sql route. Still not clear what the restriction is. If you were writing SQL you'

Re: call function of class instance with no assigned name?

2009-05-05 Thread George Oliver
On May 5, 11:59 am, Dave Angel wrote: > 1) forget about getattr() unless you have hundreds of methods in your > map. The real question is why you need two maps. What good is the > "command string" doing you? Why not just map the keyvalues directly > into function objects? Thanks for the repl

Numpy on python 2.7a

2009-05-05 Thread A. Cavallo
Hi, I'm trying to compile numpy using my own pet project based on the python svn code (that's the reason for the 2.7a tag). It is essentially a /opt python installation and it tailored for linux: its main goal is to be installed in parallel so it won't collide with a system installed python (t

Re: Which one is best Python or Java for developing GUI applications?

2009-05-05 Thread Pascal Chambon
Chris Rebert a écrit : On Tue, May 5, 2009 at 12:26 AM, Paul Rudin wrote: Paul Rubin writes: srinivasan srinivas writes: Could you tell me does Python have any advantages over Java for the development of GUI applications? Yes.

Re: Self function

2009-05-05 Thread Paul Rubin
Steven D'Aprano writes: > def rvisit(node): > print node > if node and node.link is not None: > rvisit(node.link) Less redundant (remember the extra "recursion" doesn't cost anything if the compiler is sane enough to turn it into a jump): def rvisit(node): print node i

Re: desperately looking for a howto on running my wxPython app on Vista

2009-05-05 Thread Mike Driscoll
On May 5, 11:43 am, Paul Sijben wrote: > Mike Driscoll wrote: > > On Apr 29, 4:17 am, Paul Sijben wrote: > >> Is there any way to check which is the offending pyd/dll?  (normally > >> Vista does not give out much data on what went wrong) > > >> Paul > > > You might be able to find it using the De

Re: call function of class instance with no assigned name?

2009-05-05 Thread Dave Angel
George Oliver wrote: hi, I'm a Python beginner with a basic question. I'm writing a game where I have keyboard input handling defined in one class, and command execution defined in another class. The keyboard handler class contains a dictionary that maps a key to a command string (like 'h': 'left

Re: thc v0.3 - txt to html converter - better code?

2009-05-05 Thread Stefan Behnel
Florian Wollenschein wrote: > here's some code of thc, my txt to html converter programmed with Python > and pyQT4: > --- > > if self.rdioBtnTransitional.isChecked(): > if self.cmboBoxLang.currentText() == "Eng

Re: help for documentation and license

2009-05-05 Thread CTO
On May 5, 2:30 pm, Gökhan SEVER wrote: > Hi, > > Even though I don't know what your project does, you will need to use > "Sphinx" to create semi-automatic documentation out of your project. > > I would recommend you to take a look a quality "free" Python module: > Matplotlib (http://matplotlib.sou

Re: help for documentation and license

2009-05-05 Thread Gökhan SEVER
Hi, Even though I don't know what your project does, you will need to use "Sphinx" to create semi-automatic documentation out of your project. I would recommend you to take a look a quality "free" Python module: Matplotlib (http://matplotlib.sourceforge.net/index.html) Go ahead, and check out the

Re: SQL and CSV

2009-05-05 Thread Matimus
On May 5, 9:25 am, Nick wrote: > On May 5, 5:19 pm, Tim Golden wrote: > > > > > Nick wrote: > > > I have a requirement to read a CSV file. Normally, no problem, just > > > import CSV and slurp the file up. > > > > However, in this case I want to filter out lines that have fields set > > > to part

Re: list comprehension question

2009-05-05 Thread J. Cliff Dyer
On Tue, 2009-05-05 at 12:15 -0400, J Kenneth King wrote: > Emile van Sebille writes: > > > On 5/1/2009 7:31 AM J Kenneth King said... > >> Chris Rebert writes: > >>> b = [] > >>> for pair in a: > >>> for item in pair: > >>> b.append(item) > >> > >> This is much more clear than a nest

help for documentation and license

2009-05-05 Thread Murali kumar
hi all.. I finished my application using python 2.6 and wxpython 2.8.9 >> I want to generate documentation for my application.. please suggest me and provide links to generate documents in easy way.. >> I want to host my product as open source.. I'dont know about licensing.. help me

Re: Re: list comprehension question

2009-05-05 Thread J. Cliff Dyer
On Fri, 2009-05-01 at 13:00 -0400, John Posner wrote: > Shane Geiger wrote: > >if type(el) == list or type(el) is tuple: > A tiny improvement: > > if type(el) in (list, tuple): > Another alternative, which might be useful in some cases: if hasattr(el, '__iter__'): This co

Re: Is there is any way to send messages to chunk of emails ID's concurrently using smptlib

2009-05-05 Thread Minesh Patel
On Mon, May 4, 2009 at 2:01 PM, Piet van Oostrum wrote: >> gganesh (g) wrote: > >>g> Hi friends, >>g> I suppose sendmail() can send mails one by one ,how to send mails >>g> concurrently , >>g> It would be very grateful,if someone could point out a solution. > You can always use twisted which

Re: Code works fine except...

2009-05-05 Thread MRAB
Ross wrote: On May 5, 12:32 am, John Yeung wrote: On May 5, 1:12 am, John Yeung wrote: [...] the problem may require bigger guns (either much better math or much more sophisticated programming). Yes, I'm responding to myself. Well, I went ahead with the approach I mentioned earlier, genera

Re: call function of class instance with no assigned name?

2009-05-05 Thread George Oliver
On May 5, 9:01 am, Chris Rebert wrote: > On Tue, May 5, 2009 at 8:52 AM, George Oliver > wrote: > > I create instances of these classes in a list attached to a third, > > 'brain' class. > > You could exploit Python's dynamism by using the getattr() function: Thanks for the responses -- I shou

Re: for with decimal values?

2009-05-05 Thread J. Cliff Dyer
On Sun, 2009-05-03 at 19:48 -0700, alex23 wrote: > On May 4, 11:41 am, Esmail wrote: > > All this discussion makes me wonder if it would be a good idea > > for Python to have this feature (batteries included and all) - it > > would have its uses, no? > > Well, sometimes more discussion == less co

Re: list comprehension question

2009-05-05 Thread Emile van Sebille
On 5/5/2009 9:15 AM J Kenneth King said... List comprehensions can make a reader of your code apprehensive because it can read like a run-on sentence and thus be difficult to parse. The Python documentation discourages their use and I believe for good reason. Can you provide a link for this?

Re: desperately looking for a howto on running my wxPython app on Vista

2009-05-05 Thread Paul Sijben
Mike Driscoll wrote: > On Apr 29, 4:17 am, Paul Sijben wrote: >> Is there any way to check which is the offending pyd/dll? (normally >> Vista does not give out much data on what went wrong) >> >> Paul > > You might be able to find it using the Dependency Walker utility: > > http://www.dependen

thc v0.3 - txt to html converter - better code?

2009-05-05 Thread Florian Wollenschein
Hi all, here's some code of thc, my txt to html converter programmed with Python and pyQT4: --- if self.rdioBtnTransitional.isChecked(): if self.cmboBoxLang.currentText() == "English": file_o

Error in running python -v on Mac ox 10.5.

2009-05-05 Thread silverburgh
Hi, I run 'python -v' on Macos 10.5 but I get this error : # can't create /System/Library/Frameworks/Python.framework/Versions/ 2.5/lib/python2.5/encodings/utf_8.pyc Can you please tell me how to fix it? And why I am seeing a lot of 'install' message' when i run 'python - v'? I don't think I se

Re: problem in using sendmail in multi thread

2009-05-05 Thread Piet van Oostrum
> gganesh (g) wrote: >g> hi, >g> I'm a beginner in using Python script >g> I'm trying to send mails using multi-thread >g> I wrote >g> FROM = 'ganeshx...@.com' >g> # for more mail add';' the another mail id >g> listTo = ['g@gmail.com', 'xxjango...@gmail.com', >g> 'xx...@yahoo.co.in

Re: SQL and CSV

2009-05-05 Thread Nick
On May 5, 5:19 pm, Tim Golden wrote: > Nick wrote: > > I have a requirement to read a CSV file. Normally, no problem, just > > import CSV and slurp the file up. > > > However, in this case I want to filter out lines that have fields set > > to particular values. > > > It would be neat to be able t

Re: Any idea to emulate tail -f

2009-05-05 Thread J Kenneth King
Iain King writes: > On May 5, 7:00 am, Joel Juvenal Rivera Rivera > wrote: >> I want to make something very similar to  the command tail -f (follow a >> file), i have been trying  with some while True and some microsleeps >> (about .1 s); did someone has already done something like this? >> >> A

Re: call function of class instance with no assigned name?

2009-05-05 Thread Arnaud Delobelle
Chris Rebert writes: > On Tue, May 5, 2009 at 8:52 AM, George Oliver > wrote: >> hi, I'm a Python beginner with a basic question. I'm writing a game >> where I have keyboard input handling defined in one class, and >> command execution defined in another class. The keyboard handler >> class con

Re: list comprehension question

2009-05-05 Thread J Kenneth King
Emile van Sebille writes: > On 5/1/2009 7:31 AM J Kenneth King said... >> Chris Rebert writes: >>> b = [] >>> for pair in a: >>> for item in pair: >>> b.append(item) >> >> This is much more clear than a nested comprehension. >> >> I love comprehensions, but abusing them can lead to r

Re: SQL and CSV

2009-05-05 Thread Tim Golden
Nick wrote: I have a requirement to read a CSV file. Normally, no problem, just import CSV and slurp the file up. However, in this case I want to filter out lines that have fields set to particular values. It would be neat to be able to do something like this. select * from test.csv where stat

SQL and CSV

2009-05-05 Thread Nick
I have a requirement to read a CSV file. Normally, no problem, just import CSV and slurp the file up. However, in this case I want to filter out lines that have fields set to particular values. It would be neat to be able to do something like this. select * from test.csv where status <> "Cancele

Re: problem in using sendmail in multi thread

2009-05-05 Thread Aahz
In article <343747e9-549f-4336-9b15-522411a78...@x1g2000prh.googlegroups.com>, gganesh wrote: > >I'm a beginner in using Python script >I'm trying to send mails using multi-thread You need a separate SMTP connection for each thread. -- Aahz (a...@pythoncraft.com) <*> http://ww

Re: call function of class instance with no assigned name?

2009-05-05 Thread Chris Rebert
On Tue, May 5, 2009 at 8:52 AM, George Oliver wrote: > hi, I'm a Python beginner with a basic question. I'm writing a game > where I have keyboard input handling defined in one class, and command > execution defined in another class. The keyboard handler class > contains a dictionary that maps a k

Re: Problem with case insensitive volumes

2009-05-05 Thread spillz
On May 5, 10:02 am, Scott David Daniels wrote: > What is so tough about something like: > > base, dirs, files = next(os.walk(dirn))  # older: os.walk(dirn).next() > current = dict((name.upper() for name in dirs + files) > ... > changed = some_name == current[some_name.upper()] > ... not so fast.

call function of class instance with no assigned name?

2009-05-05 Thread George Oliver
hi, I'm a Python beginner with a basic question. I'm writing a game where I have keyboard input handling defined in one class, and command execution defined in another class. The keyboard handler class contains a dictionary that maps a key to a command string (like 'h': 'left') and the command hand

Re: Open a dialog from MainWindow - pyQT4 - Beginner :-)

2009-05-05 Thread Florian Wollenschein
nickga...@gmail.com wrote: On May 4, 7:31 pm, Florian Wollenschein wrote: Dear folks, I'm just working on a pyQT4 version of my txt to html converter thc (see listick.org for details). I created the MainWindow with QT Designer and then converted it to .py with pyuic4. It works well so far. Th

Re: for with decimal values?

2009-05-05 Thread Sion Arrowsmith
Gabriel Genellina wrote: >En Sun, 03 May 2009 17:41:49 -0300, Zentrader >escribió: >> There is no need for a function or a generator. A for() loop is a >> unique case of a while loop >> ## for i in range(-10.5, 10.5, 0.1): >> ctr = -10.5 >> while ctr < 10.5: >>print ctr >>ctr += 0.1 >

Python-URL! - weekly Python news and links (May 5)

2009-05-05 Thread Gabriel Genellina
QOTW: "... [S]omebody's gotta put up some resistance to cute shortcuts, or we'll find ourselves back with Perl." - Peter Pearson http://groups.google.com/group/comp.lang.python/msg/2ce1b43e4d40528f How much memory occupies an object? http://groups.google.com/group/comp.lang.pytho

Re: Code works fine except...

2009-05-05 Thread Ross
On May 5, 12:32 am, John Yeung wrote: > On May 5, 1:12 am, John Yeung wrote: > > > [...] the problem may require bigger guns (either much better > > math or much more sophisticated programming). > > Yes, I'm responding to myself. > > Well, I went ahead with the approach I mentioned earlier, gener

Re: object query assigned variable name?

2009-05-05 Thread Sion Arrowsmith
John O'Hagan wrote: >I can see that it's tantalizing, though, because _somebody_ must know about >the assignment; after all, we just executed it! Except we haven't, if we're talking about reporting from the object's __init__: >>> class Brian: ... def __init__(self): ... print "I'm

Re: Problem with case insensitive volumes

2009-05-05 Thread Scott David Daniels
spillz wrote: os;walk will tell you the correct case for each node. So if it gives you a different case than the stored form, you have your answer. Thanks, although I was hoping that wouldn't be the answer (I have to compare a LOT of files). What is so tough about something like: base, dirs

Re: Open a dialog from MainWindow - pyQT4 - Beginner :-)

2009-05-05 Thread nickgaens
On May 4, 7:31 pm, Florian Wollenschein wrote: > Dear folks, > > I'm just working on a pyQT4 version of my txt to html converter thc (see > listick.org for details). > > I created the MainWindow with QT Designer and then converted it to .py > with pyuic4. It works well so far. Then I created a new

Re: change some lines from a read file

2009-05-05 Thread Anthra Norell
utab wrote: On May 4, 10:06 pm, Anthra Norell wrote: utab wrote: Dear all, I have to change some lines from a template file, which is rather long to paste here, but I would like to make some parts of some lines optional with my command line arguments but I could not see this di

Re: exit a program gracefully

2009-05-05 Thread Scott David Daniels
Lawrence D'Oliveiro wrote: It would be nice if Python offered a straightforward equivalent to ... do /*once*/ { ... do stuff ... if (check1_failed) break; ... do even more stuff ... } while (false); ... cleanup goes here ... What's

Re: Any idea to emulate tail -f

2009-05-05 Thread Paul Scott
On Mon, 2009-05-04 at 23:50 -0700, CTO wrote: > You might want to try http://pyinotify.sourceforge.net/. Works well on > Linux systems. Otherwise, I'd watch the mtime on the file and fork to > handle the change. > pyinotify works really well. If you need to watch a file, simply use the IN_MODIFY

Re: find sublist inside list

2009-05-05 Thread bearophileHUGS
John O'Hagan: > li=['a', 'c', 'a', 'c', 'c', 'g', 'a', 'c'] > for i  in range(len(li)): >     if li[i:i + 2] == ['a', 'c']: >         li[i:i + 2] = ['6'] Oh well, I have done a mistake, it seems. Another solution then: >>> 'acaccgac'.replace("ac", chr(6)) '\x06\x06cg\x06' Bye, bearophile -- http

Re: Question of UTF16BE encoding / decoding

2009-05-05 Thread Napalmski
In article , metolone+gm...@gmail.com says... > > > import binascii > s = '004e006100700061006c006d' > h = binascii.unhexlify(s) > print h.decode('utf-16-be') > > -Mark And: name2 = name2.encode("utf-16-be") print binascii.b2a_hex(name2) to re-encode, Thank you, much appreciated! -- http://m

Re: Profiling gives very different predictions of best algorithm

2009-05-05 Thread Rick
On May 2, 9:10 am, Rick wrote: > I was posting to the list mostly because I would like to know whether > I can do something different when I profile my code so that it give > results that correspond more closely to those that the nonprofiling > results give. A good comment that was emailed to me

Re: Problem with case insensitive volumes

2009-05-05 Thread spillz
> os;walk will tell you the correct case for each node.   So if it gives > you a different case than the stored form, you have your answer. Thanks, although I was hoping that wouldn't be the answer (I have to compare a LOT of files). -- http://mail.python.org/mailman/listinfo/python-list

Re: Can someone please explain to me this code?

2009-05-05 Thread CTO
> root.change_attributes(event_mask = X.KeyPressMask) This asks X to send this application keypress events > root.grab_key(keycode, X.AnyModifier, 1,X.GrabModeAsync, X.GrabModeAsync) This tells X to grab the keyboard if the given keycode is generated and any modifier is pressed, not to stop proc

Is there is any way to send messages to chunk of emails ID's concurrently using smptlib

2009-05-05 Thread gganesh
Hi friends, I suppose sendmail() can send mails one by one ,how to send mails concurrently , It would be very grateful,if someone could point out a solution. Thanks Ganesh -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing.Queue - I want to end.

2009-05-05 Thread Luis Alberto Zarrabeitia Gomez
Quoting Cameron Simpson : > | And as it happens I have an IterableQueue class right here which does > | _exact_ what was just described. You're welcome to it if you like. > | Added bonus is that, as the name suggests, you can use the class as > | an iterator: > | for item in iterq: > | ...

New Module Proposal

2009-05-05 Thread Riccardo Fadiga
Greetings, I'm a basic python coder, and I wrote for myself a module wich has many function regarding encryption/decryption with Caesar, Vigenere, RSA and many more ciphers. People told me that it would be useful that it would be included in stardard Python distribution. I'll send you a copy of th

Re: Self function

2009-05-05 Thread Arnaud Delobelle
On 5 May, 13:33, Luis Zarrabeitia wrote: > On Tuesday 05 May 2009 02:46:58 am Chris Rebert wrote: > > > > > Adding syntax is EVIL(tm) for it angers the Gods of Backwards > > Compatibility, and this proposal is completely unnecessary because you > > could instead just write: > [...] > > And there

How to build Python 2.6.2 on HP-UX Itanium with thread support?

2009-05-05 Thread henning . vonbargen
Our program that makes use of cx_Oracle and multi-threading (and works fine on Windows, Linux and other platforms, including HP-UX PA-RISC), fails to run on HP-UX Itanium. When trying to start the first daemon thread, the program raises an exception: ... File "/usr/local/lib/python2.6/threading.p

Re: Self function

2009-05-05 Thread Luis Zarrabeitia
On Tuesday 05 May 2009 04:25:49 am Carl Banks wrote: > Iteration should be used instead of recursion anywhere a tail- > recursive algorithm is possible.  Recursion should be used only when > tail-recursion is not possible. Why? Is it because most languages suck at recursion (specially python, as t

Re: Self function

2009-05-05 Thread Luis Zarrabeitia
On Tuesday 05 May 2009 03:51:19 am Steven D'Aprano wrote: > def ivisit(node): >     print node >     while node and node.link is not None: >         node = node.link >         print node > > def rvisit(node): >     print node >     if node and node.link is not None: >         rvisit(node.link) > >

  1   2   >