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 <[email protected]> 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, >>          re.split(r'(\d\d\d)',str

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 b

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 McCo

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 wrote: > >> 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

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 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 the quickest way to to create such an ob

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 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 problem may shift fr

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

2010-08-05 Thread Jon Clements
On 5 Aug, 08:25, Brandon McCombs 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 line of

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

2010-08-05 Thread jhermann
On Aug 2, 7:34 pm, John Nagle 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'] -- http://mail.python.org/mailman/list

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 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 class types like C++,

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

2010-08-05 Thread Lawrence D'Oliveiro
In message <[email protected]>, 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 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 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)) -- http://mail.python.org/mailman/listinfo/python-list

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

2010-08-05 Thread Lawrence D'Oliveiro
In message , 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. -- http://mail.python.org/mailman/listinfo/python-list

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 certainl

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

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] ca

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? Chr

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 st

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

2010-08-05 Thread DarkBlue
On Aug 5, 7:06 pm, 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

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 in

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 writes: > In message , 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 reminded of something I once read in some MS blurb... it described

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 construc

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 us

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 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; > > pValue = P

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 Management,

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

2010-08-05 Thread small Pox
http://www.youtube.com/watch?v=JYpkWbdOvrM&feature=related http://www.youtube.com/watch?v=0y-Ct1NpxWA&feature=related http://www.youtube.com/watch?v=u7dKl-T6ZFA&feature=related http://www.youtube.com/watch?v=1DtUtvDrbIM&feature=related http://www.youtube.com/watch?v=pOESV8kg1JE&feature=related

Re: A new syntax for writing tests

2010-08-05 Thread jfine
On 5 Aug, 10:17, Jean-Michel Pichavant 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 before, and > >

Re: subprocess escaping POpen?!

2010-08-05 Thread Grant Edwards
On 2010-08-05, Chris Withers 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 want to s

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 th

Re: simple (I hope!) problem

2010-08-05 Thread samwyse
On Aug 5, 4:32 am, Jean-Michel Pichavant wrote: > samwyse wrote: > > On Aug 3, 1:20 am, Steven D'Aprano > [email protected]> 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 w

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 K&R 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, assu

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 s

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 __n

Re: A new syntax for writing tests

2010-08-05 Thread Jean-Michel Pichavant
jfine wrote: On 5 Aug, 10:17, Jean-Michel Pichavant 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 be

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 thous_

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 wrote: > On Jul 23, 9:27 pm, TheFlyingDutchman wrote: > > > > > On Jul 23, 12:06 pm, Emmy Noether wrote: > > > > Title   PortableLISPinterpreter > > > Creator/Author  Cox, L.A. Jr. ; Taylor, W.P. > > > Publication Date        1978 May 31 > > > OSTI Identifier OST

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 having

Re: Fascinating interview by Richard Stallman on Russia TV

2010-08-05 Thread nanothermite911fbibustards
On Jul 18, 4:48 am, Richard Heathfield wrote: > Richard Heathfield > Email: -http://www. +rjh@ > "Usenet is a strange place" - dmr 29 July 1999 > Sig line vacant - apply within http://www.youtube.com/watch?v=JYpkWbdOvrM&feature=related http://www.youtube.com/watch?v=0y-C

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

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

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 - h

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: http://bitbucket.org/geer

Re: assigning variables from list data

2010-08-05 Thread Benjamin Kaplan
On Thu, Aug 5, 2010 at 7:26 AM, 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

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: http:

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 api-ide

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 wrote: > jfine wrote: > > On 5 Aug, 10:17, Jean-Michel Pichavant 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

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 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

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 t

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 syntacti

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

2010-08-05 Thread Neil Cerutti
On 2010-08-05, Brandon McCombs 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 > self.newP

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

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 simila

Re: easy question on parsing python: "is not None"

2010-08-05 Thread Ben Finney
wheres pythonmonks 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’ is a single operator which

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 wro

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 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) >

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 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 operato

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 -- http://mail.py

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 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) >

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 wrote: > On Wed, 4 Aug 2010 16:40:45 -0700 (PDT), Íßêïò > declaimed the following in > gmane.comp.python.general: > > >                    for entry in row: > >                            entry = datetime.datetime.strftime( entry, '%d > > %b, %H:%M' ) #!!! > >

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 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 joyful work each f

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 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

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 lo

Re: easy question on parsing python: "is not None"

2010-08-05 Thread Dave Angel
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(

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(

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 writes: > OK, I have a copy of K&R 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 rely on" is not relevant for

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 inst

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

Re: pre-uninstall script in bdist_wininst

2010-08-05 Thread Nils
On 5 Aug., 20:26, Nils 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 ( ''' ''' ) date = row[2].strftime( '%d %b, %H:%M' ) print ( ''' %s %s %s ''' % ( row[0], row[1], date ) ) Unfortunately had to ditch the 'for entry in row' line because couldn't iterate over the it

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 ( ''' ''' ) date = row[2].strftime( '%d %b, %H:%M' ) print ( ''' %s %s %s ''' % ( row[0], row[1], date ) ) Unfortunately had to ditch the 'for entry in row' line because cou

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

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 explici

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

2010-08-05 Thread Britt
On Aug 1, 9:34 pm, Albert Hopkins 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 Collection (which inclu

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 wrote: > On 08/05/10 13:52, Νίκος wrote: > > > dataset = cursor.fetchall() > > > for row in dataset: > >      print ( '''  ''' ) As i have it the returned 'dataset' is stored line per line to 'row'. So, 'dataset' in here is a 'list of tuples' right? and 'row' in here

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 >> >

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 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 haven't

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 o

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 (Ann

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 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" and "is not" test whether

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 Chase wrote: dataset = cursor.fetchall() for row in dataset: print ( '''''' ) So, 'dataset' in here is a 'list of tuples' right? and 'row' in here is a tuple form the above list of tuples right? Am i understanding this correct

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

2010-08-05 Thread Roy Smith
In article , Lawrence D'Oliveiro wrote: > In message , 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. Yes, there are a few corner cases where valid C syntax has different semantics in

Re: defining, raising and catching exceptions

2010-08-05 Thread MRAB
Chris Hare wrote: 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') The class Exception saves its arguments in the 'args' instance attribute, and when it prints the ex

Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-05 Thread W. eWatson
It's been awhile since I've used python, and I recall there is a way to find the version number from the IDLE command line prompt. dir, help, __version.__? I made the most minimal change to a program, and it works for me, but not my partner. He gets Traceback (most recent call last): File

Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-05 Thread Steven D'Aprano
On Thu, 05 Aug 2010 17:55:30 -0700, W. eWatson wrote: > I'm pretty sure he has the same version of Python, 2.5, but perhaps not > the numpy or scipy modules. I need to find out his version numbers. It's only a convention, but the usual way is to check the __version__ attribute. It works for Nump

Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-05 Thread MRAB
W. eWatson wrote: It's been awhile since I've used python, and I recall there is a way to find the version number from the IDLE command line prompt. dir, help, __version.__? I made the most minimal change to a program, and it works for me, but not my partner. He gets Traceback (most recent

Re: defining, raising and catching exceptions

2010-08-05 Thread Chris Hare
On Aug 5, 2010, at 7:37 PM, MRAB wrote: > Chris Hare wrote: >> 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') > The class Exception saves its arguments in

  1   2   >