[Python-Dev] Python 2.6.6 release candidate 1 now available

2010-08-05 Thread Barry Warsaw
___ Python-Dev mailing list python-...@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/barry%40python.org -- http://mail.python.org/mailman/listinfo/python-announce-list

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread Paul Rubin
John Nagle na...@animats.com writes: def editmoney(n) : return((,.join(reduce(lambda lst, item : (lst + [item]) if item else lst, re.split(r'(\d\d\d)',str(n)[::-1]),[])))[::-1]) Too obscure. I usually use something like this: def editmoney(n): if n 0: return

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread Steven D'Aprano
On Wed, 04 Aug 2010 21:33:31 -0700, John Nagle wrote: There's got to be a better way to do this: def editmoney(n) : return((,.join(reduce(lambda lst, item : (lst + [item]) if item else lst, re.split(r'(\d\d\d)',str(n)[::-1]),[])))[::-1]) What does the name

Re: newbie problem with str.replace

2010-08-05 Thread Daniel da Silva
Also, for bestandsnaam in dirs and files: is probably not doing what you want. Use + to concatenate lists. Daniel On Wed, Aug 4, 2010 at 6:30 AM, Mike Kent mrmak...@cox.net wrote: On Aug 4, 9:10 am, BobAalsma bob.aal...@aalsmacons.nl wrote: I'm working on a set of scripts

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread Peter Otten
John Nagle wrote: There's got to be a better way to do this: def editmoney(n) : return((,.join(reduce(lambda lst, item : (lst + [item]) if item else lst, re.split(r'(\d\d\d)',str(n)[::-1]),[])))[::-1]) editmoney(0) '0' editmoney(13535) '13,535'

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread geremy condra
On Wed, Aug 4, 2010 at 11:30 PM, Peter Otten __pete...@web.de wrote: John Nagle wrote: There's got to be a better way to do this: def editmoney(n) :      return((,.join(reduce(lambda lst, item : (lst + [item]) if          item else lst,          

new to python - trouble calling a function from another function

2010-08-05 Thread Brandon McCombs
Hello, I'm building an elevator simulator for a class assignment. I recently ran into a roadblock and don't know how to fix it. For some reason, in my checkQueue function below, the call to self.goUp() is never executed. It is on the last line of code I pasted in. I can put print statements

Re: new to python - trouble calling a function from another function

2010-08-05 Thread Navkirat Singh
I was looking at the code, I dont have much time to go through it, but I might have found a typo - yield (p.destination - self.currenteFloor) , I think it should be currentFloor.Maybe thats your problem. Will look into the code more later. Regards, Nav On 05-Aug-2010, at 12:55 PM, Brandon

Re: Python Script Cannot Write to Directory

2010-08-05 Thread News123
On 08/04/2010 09:27 AM, Chris Rebert wrote: On Wed, Aug 4, 2010 at 12:21 AM, News123 news1...@free.fr wrote: snip 3.) try following python import os print os.getcwd() import shutil shutil(YOUR_SOURCE_FILE_NAME,DESTINATION_DIRECTORY/DSTNTN_FILE_NAME) WTF; modules aren't callable. Typo?

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread Steven D'Aprano
On Thu, 05 Aug 2010 00:22:57 -0700, geremy condra wrote: locale.setlocale(locale.LC_ALL, ) 'de_DE.UTF-8' print locale.currency(13535, grouping=True) 13.535,00 € print locale.format(%d, 13535, grouping=True) 13.535 Peter I had literally no idea this existed. Thanks. I knew it existed,

Re: A new syntax for writing tests

2010-08-05 Thread Jean-Michel Pichavant
Jonathan Fine wrote: Hi I just discovered today a new syntax for writing tests. The basic idea is to write a function that contains some statements, and run it via a decorator. I wonder if anyone had seen this pattern before, and how you feel about it. For myself, I quite like it. Let's

Re: simple (I hope!) problem

2010-08-05 Thread Jean-Michel Pichavant
samwyse wrote: On Aug 3, 1:20 am, Steven D'Aprano steve-REMOVE- t...@cybersource.com.au wrote: On Mon, 02 Aug 2010 17:19:46 -0700, samwyse wrote: Fortunately, I don't need the functionality of the object, I just want something that won't generate an error when I use it. So, what is

Re: simple integer subclass

2010-08-05 Thread Stefan Schwarzer
Hi Andreas, On 2010-08-03 12:15, Andreas Pfrengle wrote: On 3 Aug., 03:22, Carl Banks pavlovevide...@gmail.com wrote: Thinking about it, it might really be dangerous to coerce always to int1, since sometimes I might want a normal int as result (I can't tell yet for sure). Yes, that way your

Re: new to python - trouble calling a function from another function

2010-08-05 Thread Jon Clements
On 5 Aug, 08:25, Brandon McCombs n...@none.com wrote: Hello, I'm building an elevator simulator for a class assignment. I recently ran into a roadblock and don't know how to fix it. For some reason, in my checkQueue function below, the call to self.goUp() is never executed. It is on the last

Re: Behavior of re.split on empty strings is unexpected

2010-08-05 Thread jhermann
On Aug 2, 7:34 pm, John Nagle na...@animats.com wrote:   s2 =   HELLO   THERE     kresplit4 = re.compile(r'\W+', re.UNICODE)   kresplit4.split(s2) ['', 'HELLO', 'THERE', ''] I still get empty strings. re.findall(r\w+, a b c ) ['a', 'b', 'c'] --

Re: Nice way to cast a homogeneous tuple

2010-08-05 Thread Lie Ryan
On Wed, 28 Jul 2010 15:58:29 +0200, Ulrich Eckhardt eckha...@satorlaser.com wrote: wheres pythonmonks wrote: Thanks ... I thought int was a type-cast (like in C++) so I assumed I couldn't reference it. Firstly, int is a class. Python doesn't make a distinction between builtin types and

Re: Why is python not written in C++ ?

2010-08-05 Thread Lawrence D'Oliveiro
In message 7xocdi56cp@ruckus.brouhaha.com, Paul Rubin wrote: I'd say the Ada standardizers went to a great deal of trouble to specify and document stuff that other languages simply leave undefined, leaving developers relying on implementation-specific behavior that's not part of the

Re: Why is python not written in C++ ?

2010-08-05 Thread Lawrence D'Oliveiro
In message roy-6bcfa7.22564104082...@news.panix.com, Roy Smith wrote: C++, for all its flaws, had one powerful feature which made it very popular. It is a superset of C. Actually, it never was. -- http://mail.python.org/mailman/listinfo/python-list

Re: Nice way to cast a homogeneous tuple

2010-08-05 Thread Lie Ryan
On Wed, 28 Jul 2010 09:15:24 -0400, wheres pythonmonks wherespythonmo...@gmail.com wrote: A new python convert is now looking for a replacement for another perl idiom. A functional alternative: l = ... seqint = compose(map, int) print f(seqint(l)) --

Re: Why is there no platform independent way of clearing a terminal?

2010-08-05 Thread Lawrence D'Oliveiro
In message mailman.1601.1280974847.1673.python-l...@python.org, David Robinow wrote: Lawrence, you've been asking a lot of off-topic questions about Microsoft Windows. You’ve got to be kidding. Look at the number of Windows-specific questions this groups is already full of. --

Re: new to python - trouble calling a function from another function

2010-08-05 Thread Ulrich Eckhardt
Brandon McCombs wrote: I'm building an elevator simulator for a class assignment. I recently ran into a roadblock and don't know how to fix it. For some reason, in my checkQueue function below, the call to self.goUp() is never executed. [...] sorry about the formatting While I can certainly

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread Chris Withers
Peter Otten wrote: locale.setlocale(locale.LC_ALL, (en_US, UTF-8)) 'en_US.UTF8' print locale.currency(13535, grouping=True) $13,535.00 Okay, so if I'm writing a wsgi app, and I want to format depending on the choices of the currently logged in users, what would you recommend? I can't do

subprocess escaping POpen?!

2010-08-05 Thread Chris Withers
Hi All, I have a script that does the following: from subprocess import Popen,PIPE,STDOUT def execute(command,cwd): return Popen( command, stderr=STDOUT, stdout=PIPE, universal_newlines=True, cwd=cwd, shell=True, ).communicate()[0]

Re: subprocess escaping POpen?!

2010-08-05 Thread Chris Withers
Wolfgang Rohdewald wrote: On Donnerstag 05 August 2010, Chris Withers wrote: ...then the output is indeed captured. So, what is svn doing differently? How is it escaping its jail? maybe it does not read from stdin but directly from /dev/tty But why only the request for auth credentials?

Re: subprocess escaping POpen?!

2010-08-05 Thread Wolfgang Rohdewald
On Donnerstag 05 August 2010, Chris Withers wrote: ...then the output is indeed captured. So, what is svn doing differently? How is it escaping its jail? maybe it does not read from stdin but directly from /dev/tty -- Wolfgang -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess escaping POpen?!

2010-08-05 Thread Jean-Michel Pichavant
Chris Withers wrote: Hi All, I have a script that does the following: from subprocess import Popen,PIPE,STDOUT def execute(command,cwd): return Popen( command, stderr=STDOUT, stdout=PIPE, universal_newlines=True, cwd=cwd, shell=True,

Re: subprocess escaping POpen?!

2010-08-05 Thread Chris Withers
Jean-Michel Pichavant wrote: You did not redirect stdin, so it is expected you can still read input from the console. Okay, so if I definitely wanted no input, what should I pass as the stdin parameter to the POpen constructor? And it looks like svn is writting the credentials prompt on

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread DarkBlue
On Aug 5, 7:06 pm, Chris Withers ch...@simplistix.co.uk wrote: Peter Otten wrote: locale.setlocale(locale.LC_ALL, (en_US, UTF-8)) 'en_US.UTF8' print locale.currency(13535, grouping=True) $13,535.00 Okay, so if I'm writing a wsgi app, and I want to format depending on the choices of the

Re: Why is python not written in C++ ?

2010-08-05 Thread Christoffer Viken
C++ is actually not that bad. Can't compare it to C, but nothing compares to C... I think the bad reputation it got (and still has) is from Microsoft's visual studio IDE (that was and still is horrible) A lot of good applications are written in C++, but many bad ones as well. Sorry for swearing

PyInt_FromLong gives segfault on small numbers (257)

2010-08-05 Thread Marcos Prieto
Hi, I'm trying to call python (python 2.6) functions from C++ using MS VC+ + 6.0 and any calls to PyInt_FromLong with numbers below 257 give me exceptions, no problems with bigger numbers PyObject *pValue; pValue = PyInt_FromLong(1L); (or pValue = PyInt_FromLong(1); Any ideas of what can I be

Re: Why is python not written in C++ ?

2010-08-05 Thread Paul Rudin
Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes: In message roy-6bcfa7.22564104082...@news.panix.com, Roy Smith wrote: C++, for all its flaws, had one powerful feature which made it very popular. It is a superset of C. Actually, it never was. Wondering off topic a bit - I am

Re: subprocess escaping POpen?!

2010-08-05 Thread Ryan Kelly
On Thu, 2010-08-05 at 12:58 +0100, Chris Withers wrote: Jean-Michel Pichavant wrote: You did not redirect stdin, so it is expected you can still read input from the console. Okay, so if I definitely wanted no input, what should I pass as the stdin parameter to the POpen constructor?

Re: subprocess escaping POpen?!

2010-08-05 Thread Wolfgang Rohdewald
On Donnerstag 05 August 2010, Chris Withers wrote: But why only the request for auth credentials? for security reasons I suppose - make sure a human enters the password -- Wolfgang -- http://mail.python.org/mailman/listinfo/python-list

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread Peter Otten
Chris Withers wrote: Peter Otten wrote: locale.setlocale(locale.LC_ALL, (en_US, UTF-8)) 'en_US.UTF8' print locale.currency(13535, grouping=True) $13,535.00 Okay, so if I'm writing a wsgi app, and I want to format depending on the choices of the currently logged in users, what would you

Re: PyInt_FromLong gives segfault on small numbers (257)

2010-08-05 Thread Antoine Pitrou
On Thu, 5 Aug 2010 05:04:36 -0700 (PDT) Marcos Prieto mark...@gmail.com wrote: Hi, I'm trying to call python (python 2.6) functions from C++ using MS VC+ + 6.0 and any calls to PyInt_FromLong with numbers below 257 give me exceptions, no problems with bigger numbers PyObject *pValue;

Re: subprocess escaping POpen?!

2010-08-05 Thread Chris Withers
Wolfgang Rohdewald wrote: On Donnerstag 05 August 2010, Chris Withers wrote: But why only the request for auth credentials? for security reasons I suppose - make sure a human enters the password Well yes, but what if you actually want to script it? Chris -- Simplistix - Content

*** Project for New American Python, Scheme, Emacs, Unix Century - TUTORIAL VIDEOS ***

2010-08-05 Thread small Pox
http://www.youtube.com/watch?v=JYpkWbdOvrMfeature=related http://www.youtube.com/watch?v=0y-Ct1NpxWAfeature=related http://www.youtube.com/watch?v=u7dKl-T6ZFAfeature=related http://www.youtube.com/watch?v=1DtUtvDrbIMfeature=related http://www.youtube.com/watch?v=pOESV8kg1JEfeature=related

Re: A new syntax for writing tests

2010-08-05 Thread jfine
On 5 Aug, 10:17, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Jonathan Fine wrote: Hi I just discovered today anewsyntaxfor writing tests.  The basic idea is to write a function that contains some statements, and run it via a decorator.  I wonder if anyone had seen this pattern

Re: subprocess escaping POpen?!

2010-08-05 Thread Grant Edwards
On 2010-08-05, Chris Withers ch...@simplistix.co.uk wrote: Wolfgang Rohdewald wrote: On Donnerstag 05 August 2010, Chris Withers wrote: But why only the request for auth credentials? for security reasons I suppose - make sure a human enters the password Well yes, but what if you actually

Re: subprocess escaping POpen?!

2010-08-05 Thread Jean-Michel Pichavant
Chris Withers wrote: Jean-Michel Pichavant wrote: You did not redirect stdin, so it is expected you can still read input from the console. Okay, so if I definitely wanted no input, what should I pass as the stdin parameter to the POpen constructor? You do want an input don't you ? 'cause

Re: simple (I hope!) problem

2010-08-05 Thread samwyse
On Aug 5, 4:32 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: samwyse wrote: On Aug 3, 1:20 am, Steven D'Aprano steve-REMOVE- t...@cybersource.com.au wrote: On Mon, 02 Aug 2010 17:19:46 -0700, samwyse wrote: Fortunately, I don't need the functionality of the object, I just want

Re: Why is python not written in C++ ?

2010-08-05 Thread Tim Chase
On 08/05/10 05:33, Lawrence D'Oliveiro wrote: OK, I have a copy of KR 2nd Ed on a shelf within reach here. Can you point out some behaviour that C programmers might need to rely on, that is not specified in that document? need to is considerably different from might. Size of an int,

Re: subprocess escaping POpen?!

2010-08-05 Thread Kushal Kumaran
- Original message - Wolfgang Rohdewald wrote: On Donnerstag 05 August 2010, Chris Withers wrote: But why only the request for auth credentials? for security reasons I suppose - make sure a human enters the password Well yes, but what if you actually want to script it?

abstract metaclass

2010-08-05 Thread Roald de Vries
Hi all, I'm trying to create a metaclass that keeps track of its objects, and implement this as a collections.MutableMapping. That is, something like this: class type2(type, MutableMapping): ... /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/ python2.6/abc.pyc in

Re: A new syntax for writing tests

2010-08-05 Thread Jean-Michel Pichavant
jfine wrote: On 5 Aug, 10:17, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Jonathan Fine wrote: Hi I just discovered today anewsyntaxfor writing tests. The basic idea is to write a function that contains some statements, and run it via a decorator. I wonder if anyone

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread John Posner
On 8/5/2010 12:33 AM, John Nagle wrote: There's got to be a better way to do this: def editmoney(n) : return((,.join(reduce(lambda lst, item : (lst + [item]) if item else lst, re.split(r'(\d\d\d)',str(n)[::-1]),[])))[::-1]) Here's a more elegant variant, using regexp lookahead: def

Re: A portable LISP interpreter that includes all the major list-processing functions is described. A complete, annotated listing of the program's code, written in PASCAL, is included.

2010-08-05 Thread nanothermite911fbibustards
On Jul 24, 3:42 pm, Emmy Noether emmynoeth...@gmail.com wrote: On Jul 23, 9:27 pm, TheFlyingDutchman zzbba...@aol.com wrote: On Jul 23, 12:06 pm, Emmy Noether emmynoeth...@gmail.com wrote: Title   PortableLISPinterpreter Creator/Author  Cox, L.A. Jr. ; Taylor, W.P. Publication Date

assigning variables from list data

2010-08-05 Thread Chris Hare
I have a database query result (see code below). In PHP, I would have said list(var1,var2,var) = $result and each element in the list would be assigned to each of the named variables. I have my data coming out of the database, and I can see it is a list. so my question is, instead of

Re: Fascinating interview by Richard Stallman on Russia TV

2010-08-05 Thread nanothermite911fbibustards
On Jul 18, 4:48 am, Richard Heathfield r...@see.sig.invalid wrote: Richard Heathfield http://www.cpax.org.uk Email: -http://www. +rjh@ Usenet is a strange place - dmr 29 July 1999 Sig line vacant - apply within http://www.youtube.com/watch?v=JYpkWbdOvrMfeature=related

Re: subprocess escaping POpen?!

2010-08-05 Thread Chris Withers
Kushal Kumaran wrote: - Original message - Wolfgang Rohdewald wrote: On Donnerstag 05 August 2010, Chris Withers wrote: But why only the request for auth credentials? for security reasons I suppose - make sure a human enters the password Well yes, but what if you

Re: subprocess escaping POpen?!

2010-08-05 Thread Tim Golden
On 05/08/2010 15:38, Chris Withers wrote: Kushal Kumaran wrote: - Original message - Wolfgang Rohdewald wrote: On Donnerstag 05 August 2010, Chris Withers wrote: But why only the request for auth credentials? for security reasons I suppose - make sure a human enters the

Re: subprocess escaping POpen?!

2010-08-05 Thread Chris Withers
Tim Golden wrote: See http://pexpect.sf.net for a python version. ...which doesn't work on Windows. There is a winpexpect: http://pypi.python.org/pypi/winpexpect/1.3 Are the two api-identical? Chris -- Simplistix - Content Management, Batch Processing Python Consulting -

Re: subprocess escaping POpen?!

2010-08-05 Thread Tim Golden
On 05/08/2010 15:49, Chris Withers wrote: Tim Golden wrote: See http://pexpect.sf.net for a python version. ...which doesn't work on Windows. There is a winpexpect: http://pypi.python.org/pypi/winpexpect/1.3 Are the two api-identical? From the bitbucket page:

Re: assigning variables from list data

2010-08-05 Thread Benjamin Kaplan
On Thu, Aug 5, 2010 at 7:26 AM, Chris Hare ch...@labr.net wrote: I have a database query result (see code below).  In PHP, I would have said list(var1,var2,var) = $result and each element in the list would be assigned to each of the named variables.  I have my data coming out of the

Re: subprocess escaping POpen?!

2010-08-05 Thread Chris Withers
Tim Golden wrote: On 05/08/2010 15:49, Chris Withers wrote: Tim Golden wrote: See http://pexpect.sf.net for a python version. ...which doesn't work on Windows. There is a winpexpect: http://pypi.python.org/pypi/winpexpect/1.3 Are the two api-identical? From the bitbucket page:

Re: subprocess escaping POpen?!

2010-08-05 Thread Tim Golden
On 05/08/2010 15:56, Chris Withers wrote: Tim Golden wrote: On 05/08/2010 15:49, Chris Withers wrote: Tim Golden wrote: See http://pexpect.sf.net for a python version. ...which doesn't work on Windows. There is a winpexpect: http://pypi.python.org/pypi/winpexpect/1.3 Are the two

Re: assigning variables from list data

2010-08-05 Thread Tim Chase
On 08/05/10 09:26, Chris Hare wrote: I have a database query result (see code below). In PHP, I would have said list(var1,var2,var) = $result and each element in the list would be assigned to each of the named variables. I have my data coming out of the database, and I can see it is a list. so

Re: A new syntax for writing tests

2010-08-05 Thread jfine
On 5 Aug, 14:52, Jean-Michel Pichavant jeanmic...@sequans.com wrote: jfine wrote: On 5 Aug, 10:17, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Jonathan Fine wrote: Hi I just discovered today anewsyntaxfor writing tests.  The basic idea is to write a function that contains

Are you Searching for a New IT or Telecoms Job?

2010-08-05 Thread hrdublin
Then start your Search here at JobPIMP JobPIMP is a Customised Search Engine that is crawling over 800+ Local and International Job Boards so you don't have to. JobPIMP is searching well known mainstream, niche, and less well known specialist job portals (your search results on one page). Click

Re: new to python - trouble calling a function from another function

2010-08-05 Thread Brandon McCombs
Jon Clements wrote: On 5 Aug, 08:25, Brandon McCombs n...@none.com wrote: Hello, I'm building an elevator simulator for a class assignment. I recently ran into a roadblock and don't know how to fix it. For some reason, in my checkQueue function below, the call to self.goUp() is never executed.

Re: new to python - trouble calling a function from another function

2010-08-05 Thread Brandon McCombs
Ulrich Eckhardt wrote: Brandon McCombs wrote: I'm building an elevator simulator for a class assignment. I recently ran into a roadblock and don't know how to fix it. For some reason, in my checkQueue function below, the call to self.goUp() is never executed. [...] sorry about the formatting

Re: Why is python not written in C++ ?

2010-08-05 Thread Edward Diener
On 8/2/2010 5:42 PM, Mark Lawrence wrote: On 02/08/2010 00:08, candide wrote: Python is an object oriented langage (OOL). The Python main implementation is written in pure and old C90. Is it for historical reasons? C is not an OOL and C++ strongly is. I wonder if it wouldn't be more suitable

Re: new to python - trouble calling a function from another function

2010-08-05 Thread Tommy Grav
On Aug 5, 2010, at 11:20 AM, Brandon McCombs wrote: so I missed a few lines, so sue me. The problem is that when you don't post a self contained example there is no proper way to answer your question, since the problem could be outside the part you posted. already aware. I reformatted tabs to

easy question on parsing python: is not None

2010-08-05 Thread wheres pythonmonks
How does x is not None make any sense? not x is None does make sense. I can only surmise that in this context (preceding is) not is not a unary right-associative operator, therefore: x is not None === IS_NOTEQ(X, None) Beside not in which seems to work similarly, is there other syntactical

Re: new to python - trouble calling a function from another function

2010-08-05 Thread Neil Cerutti
On 2010-08-05, Brandon McCombs n...@none.com wrote: class Elevator(Process): def __init__(self,name): Process.__init__(self,name=name) self.numPassengers = 0 self.passengerList = [] self.passengerWaitQ = [] self.currentFloor = 1 self.idle = 1

Re: easy question on parsing python: is not None

2010-08-05 Thread Roald de Vries
On Aug 5, 2010, at 5:42 PM, wheres pythonmonks wrote: How does x is not None make any sense? not x is None does make sense. I can only surmise that in this context (preceding is) not is not a unary right-associative operator, therefore: x is not None === IS_NOTEQ(X, None) Beside not in

Re: easy question on parsing python: is not None

2010-08-05 Thread Jean-Michel Pichavant
wheres pythonmonks wrote: How does x is not None make any sense? not x is None does make sense. I can only surmise that in this context (preceding is) not is not a unary right-associative operator, therefore: x is not None === IS_NOTEQ(X, None) Beside not in which seems to work similarly, is

Re: easy question on parsing python: is not None

2010-08-05 Thread Ben Finney
wheres pythonmonks wherespythonmo...@gmail.com writes: How does x is not None make any sense? In two ways: partly from the fact that Python syntax is preferentially designed to be reasonably readable to a native English reader; and partly because it makes for more obvious semantics. ‘is not’

Re: easy question on parsing python: is not None

2010-08-05 Thread wheres pythonmonks
Well, I am not convinced of the equivalence of not None and true: not None True 3 is True; False 3 is not None True P.S. Sorry for the top-post -- is there a way to not do top posts from gmail? I haven't used usenet since tin. On Thu, Aug 5, 2010 at 11:56 AM, Roald de Vries

Re: easy question on parsing python: is not None

2010-08-05 Thread Carey Tilden
On Thu, Aug 5, 2010 at 8:42 AM, wheres pythonmonks wherespythonmo...@gmail.com wrote: How does x is not None make any sense?  not x is None does make sense. I can only surmise that in this context (preceding is) not is not a unary right-associative operator, therefore: x is not None ===

Re: easy question on parsing python: is not None

2010-08-05 Thread Chris Rebert
On Thu, Aug 5, 2010 at 8:56 AM, Roald de Vries downa...@gmail.com wrote: On Aug 5, 2010, at 5:42 PM, wheres pythonmonks wrote: How does x is not None make any sense?  not x is None does make sense. I can only surmise that in this context (preceding is) not is not a unary right-associative

Re: simple integer subclass

2010-08-05 Thread Andreas Pfrengle
Hello everyone, thanks for all the suggestions. I did effort to redesign parts of the data structure the last days, but not all (only those I could easily keep track of in my code). For the rest I add +1 before the presentation and comment it. Seems the easiest way now. Andreas --

Re: easy question on parsing python: is not None

2010-08-05 Thread Chris Rebert
On Thu, Aug 5, 2010 at 8:42 AM, wheres pythonmonks wherespythonmo...@gmail.com wrote: How does x is not None make any sense?  not x is None does make sense. I can only surmise that in this context (preceding is) not is not a unary right-associative operator, therefore: x is not None ===

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread Νίκος
On 5 Αύγ, 11:55, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Wed, 4 Aug 2010 16:40:45 -0700 (PDT), Íßêïò nikos.the.gr...@gmail.com declaimed the following in gmane.comp.python.general:                    for entry in row:                            entry = datetime.datetime.strftime(

Re: A portable LISP interpreter that includes all the major list-processing functions is described. A complete, annotated listing of the program's code, written in PASCAL, is included.

2010-08-05 Thread fortunatus
On Jul 24, 6:42 pm, Emmy Noether emmynoeth...@gmail.com wrote: I have already spent 4 hours scanning/processing to a stage where I got a decent OCR which needs hand-verification of pages. I need 4 or 8 volunteers depending on whether one want to do two pages each or 1 page each. Its an hour of

Re: easy question on parsing python: is not None

2010-08-05 Thread Roald de Vries
On Aug 5, 2010, at 6:11 PM, Chris Rebert wrote: On Thu, Aug 5, 2010 at 8:56 AM, Roald de Vries downa...@gmail.com wrote: On Aug 5, 2010, at 5:42 PM, wheres pythonmonks wrote: How does x is not None make any sense? not x is None does make sense. I can only surmise that in this context

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread MRAB
John Posner wrote: On 8/5/2010 12:33 AM, John Nagle wrote: There's got to be a better way to do this: def editmoney(n) : return((,.join(reduce(lambda lst, item : (lst + [item]) if item else lst, re.split(r'(\d\d\d)',str(n)[::-1]),[])))[::-1]) Here's a more elegant variant, using regexp

Re: easy question on parsing python: is not None

2010-08-05 Thread Dave Angel
Roald de Vries wrote: div class=moz-text-flowed style=font-family: -moz-fixedOn Aug 5, 2010, at 5:42 PM, wheres pythonmonks wrote: How does x is not None make any sense? not x is None does make sense. I can only surmise that in this context (preceding is) not is not a unary right-associative

Re: easy question on parsing python: is not None

2010-08-05 Thread Ethan Furman
Roald de Vries wrote: On Aug 5, 2010, at 5:42 PM, wheres pythonmonks wrote: How does x is not None make any sense? not x is None does make sense. I can only surmise that in this context (preceding is) not is not a unary right-associative operator, therefore: x is not None === IS_NOTEQ(X,

ctypes: pointer to method

2010-08-05 Thread Martin Landa
Hi, is it possible to pass pointer to a method using ctypes. Sample code: ... G_set_error_routine(byref(self._print_error)) ... def _print_error(self, msg, type): !Redirect stderr self.log.write(msg) gives me G_set_error_routine(byref(self._print_error))

Re: new to python - trouble calling a function from another function

2010-08-05 Thread Daniel Urban
I'm building an elevator simulator for a class assignment. I recently ran into a roadblock and don't know how to fix it. For some reason, in my checkQueue function below, the call to self.goUp() is never executed. It is on the last line of code I pasted in. I can put print statements before

Re: Why is python not written in C++ ?

2010-08-05 Thread Paul Rubin
Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes: OK, I have a copy of KR 2nd Ed on a shelf within reach here. Can you point out some behaviour that C programmers might need to rely on, that is not specified in that document? C has all kinds of undefined behavior. Might need to

pre-uninstall script in bdist_wininst

2010-08-05 Thread Nils
Hi. I am using a postinstall-script like this: setup( ... scripts=['scripts\install.py'], options = { ... bdist_wininst : { install_script : install.py, ... }, } ) According to the docs in [1] this script is a) called after install

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread John Posner
On 8/5/2010 12:36 PM, MRAB wrote: You don't need to reverse the string: def thous_format(integer_string): add comma thousands separator(s) to an integer-valued string return re.sub(r(?=\d)(?=(?:\d\d\d)+$), ,, integer_string) Nice! My first encounter with a look-behind! It

Re: pre-uninstall script in bdist_wininst

2010-08-05 Thread Nils
On 5 Aug., 20:26, Nils andresen.n...@googlemail.com wrote: According to the docs in [1] [...] and with [1] I meant http://docs.python.org/distutils/builtdist.html#the-postinstallation-script Nils -- http://mail.python.org/mailman/listinfo/python-list

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread Νίκος
Hey i made it! :-) dataset = cursor.fetchall() for row in dataset: print ( ''' tr ''' ) date = row[2].strftime( '%d %b, %H:%M' ) print ( ''' td %s /td td %s /td td %s /td ''' % ( row[0], row[1], date ) ) Unfortunately had to ditch the 'for entry in row' line because couldn't

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread Tim Chase
On 08/05/10 13:52, Νίκος wrote: dataset = cursor.fetchall() for row in dataset: print ( '''tr ''' ) date = row[2].strftime( '%d %b, %H:%M' ) print ( '''td %s/td td %s/td td %s/td ''' % ( row[0], row[1], date ) ) Unfortunately had to ditch the 'for entry in

Re: subprocess escaping POpen?!

2010-08-05 Thread Nobody
On Thu, 05 Aug 2010 12:23:35 +0100, Chris Withers wrote: ...then the output is indeed captured. So, what is svn doing differently? How is it escaping its jail? maybe it does not read from stdin but directly from /dev/tty But why only the request for auth credentials? So that you can do

Re: ctypes: pointer to method

2010-08-05 Thread Nobody
On Thu, 05 Aug 2010 10:50:21 -0700, Martin Landa wrote: is it possible to pass pointer to a method using ctypes. I don't know about methods, but it works for functions. Sample code: ... G_set_error_routine(byref(self._print_error)) This won't work; you have to be more explicit,

Re: Why is python not written in C++ ?

2010-08-05 Thread Britt
On Aug 1, 9:34 pm, Albert Hopkins mar...@letterboxes.org wrote: On Mon, 2010-08-02 at 01:08 +0200, candide wrote: I would propose that in fact most programming languages are implemented in C.  Sun's (Oracle's) Java compiler and runtime are written in ANSI C. The core of the Gnu Compiler

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread Νίκος
On 5 Αύγ, 22:09, Tim Chase python.l...@tim.thechases.com wrote: On 08/05/10 13:52, Νίκος wrote: dataset = cursor.fetchall() for row in dataset:      print ( '''tr  ''' ) As i have it the returned 'dataset' is stored line per line to 'row'. So, 'dataset' in here is a 'list of tuples'

Re: A useful, but painful, one-liner to edit money amounts

2010-08-05 Thread Peter Otten
Steven D'Aprano wrote: On Thu, 05 Aug 2010 00:22:57 -0700, geremy condra wrote: locale.setlocale(locale.LC_ALL, ) 'de_DE.UTF-8' print locale.currency(13535, grouping=True) 13.535,00 € print locale.format(%d, 13535, grouping=True) 13.535 Peter I had literally no idea this existed.

defining, raising and catching exceptions

2010-08-05 Thread Chris Hare
I have a block of test code, where I am trying to raise and catch my own user defined exception class NetActiveError(RuntimeError): def __init__(self,error): self.args = error def a(): try: fh = open(me.txt, r) except Exception as (errno, errText): print

Re: easy question on parsing python: is not None

2010-08-05 Thread Benjamin Kaplan
On Thu, Aug 5, 2010 at 9:07 AM, wheres pythonmonks wherespythonmo...@gmail.com wrote: Well, I am not convinced of the equivalence of not None and true: not None True 3 is True; False 3 is not None True P.S. Sorry for the top-post -- is there a way to not do top posts from gmail?  I

Re: defining, raising and catching exceptions

2010-08-05 Thread Benjamin Kaplan
What makes you think it has to do with user-defined exceptions? try : ...raise Exception(hello) ... except Exception as (errno, errText) : ... print whatever ... Traceback (most recent call last): ValueError: need more than 1 values to unpack An Exception is an object, not a tuple of

Re: Why is python not written in C++ ?

2010-08-05 Thread Neil Hodgson
Paul Rubin: C has all kinds of undefined behavior. Might need to rely on is not relevant for this kind of issue. Ada's designers had the goal that that Ada programs should have NO undefined behavior. Ada achieves this by describing a long list of implementation defined behaviour (Annex

Re: easy question on parsing python: is not None

2010-08-05 Thread Rhodri James
On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks wherespythonmo...@gmail.com wrote: Well, I am not convinced of the equivalence of not None and true: not None True 3 is True; False 3 is not None True You're not testing for equivalence there, you're testing for identity. is

Re: defining, raising and catching exceptions

2010-08-05 Thread Chris Hare
okay - but why does the response come back like No such file or directory def b ('n', 'e', 't', ' ', 'a', 'l', 'r', 'e', 'a', 'd', 'y', ' ', 'r', 'u', 'n', 'n', 'i', 'n', 'g') On Aug 5, 2010, at 5:49 PM, Benjamin Kaplan wrote: What makes you think it has to do with user-defined exceptions?

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread Tim Chase
On 08/05/10 16:01, Νίκος wrote: On 5 Αύγ, 22:09, Tim Chasepython.l...@tim.thechases.com wrote: dataset = cursor.fetchall() for row in dataset: print ( '''tr''' ) So, 'dataset' in here is a 'list of tuples' right? and 'row' in here is a tuple form the above list of tuples right?

Re: Why is python not written in C++ ?

2010-08-05 Thread Roy Smith
In article i3e43n$v7...@lust.ihug.co.nz, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message roy-6bcfa7.22564104082...@news.panix.com, Roy Smith wrote: C++, for all its flaws, had one powerful feature which made it very popular. It is a superset of C. Actually, it

  1   2   3   >