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

2010-08-05 Thread David Cournapeau
On Fri, Aug 6, 2010 at 8:45 AM, Roy Smith wrote: > 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

Re: Import python modules from sub-directories

2010-08-05 Thread Ralf Schoenian
Navkirat Singh wrote: Hi guys, I am new to python and would like to import certain classes in sub-directories of the working directory. I was wondering how will I be able to achieve this? Regards, Nav Hi, put an empty file with the name __init__.py in your subdirectory. I call it sub1 here

Re: Import python modules from sub-directories

2010-08-05 Thread Navkirat Singh
On 06-Aug-2010, at 10:44 AM, Navkirat Singh wrote: > Hi guys, > > I am new to python and would like to import certain classes in > sub-directories of the working directory. I was wondering how will I be able > to achieve this? > > Regards, > Nav Thanks. I got it. I just put an empty __init_

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

2010-08-05 Thread John Nagle
On 8/4/2010 4:40 PM, Νίκος wrote: cursor.execute( ''' SELECT host, hits, date FROM visitors WHERE page = '%s' ORDER BY date DESC ''' % (page) ) Don't do string substitution ("%") on SQL statements. Let MySQLdb do it for you, with proper escaping: cursor.execute('''SELEC

Import python modules from sub-directories

2010-08-05 Thread Navkirat Singh
Hi guys, I am new to python and would like to import certain classes in sub-directories of the working directory. I was wondering how will I be able to achieve this? Regards, Nav -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Portability--Not very portable?

2010-08-05 Thread geremy condra
On Thu, Aug 5, 2010 at 8:28 PM, W. eWatson wrote: > On 8/5/2010 7:45 PM, geremy condra wrote: >> >> On Thu, Aug 5, 2010 at 6:50 PM, W. eWatson  wrote: >>> >>> In my on-again-off-again experience with Python for 18 months, >>> portability >>> seems an issue. >>> >>> As an example, my inexperienced

Re: Python Portability--Not very portable?

2010-08-05 Thread W. eWatson
On 8/5/2010 7:45 PM, geremy condra wrote: On Thu, Aug 5, 2010 at 6:50 PM, W. eWatson wrote: In my on-again-off-again experience with Python for 18 months, portability seems an issue. As an example, my inexperienced Python partner 30 miles away has gotten out of step somehow. I think by install

Re: Python Portability--Not very portable?

2010-08-05 Thread geremy condra
On Thu, Aug 5, 2010 at 6:50 PM, W. eWatson wrote: > In my on-again-off-again experience with Python for 18 months, portability > seems an issue. > > As an example, my inexperienced Python partner 30 miles away has gotten out > of step somehow. I think by installing a different version of numpy tha

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

2010-08-05 Thread alex23
Lawrence D'Oliveiro wrote: > You’ve got to be kidding. Look at the number of Windows-specific questions > this groups is already full of. Are you really unable to tell the difference between questions about Windows-related modules and snarky, off-topic sniping at Windows itself? -- http://mail.p

Re: pre-uninstall script in bdist_wininst

2010-08-05 Thread Mark Hammond
On 6/08/2010 4:26 AM, Nils wrote: Hi. I am using a postinstall-script like this: setup( ... scripts=['scripts\install.py'], options = { ... "bdist_wininst" : { "install_script" : "install.py", ... }, } ) According to the do

Python Portability--Not very portable?

2010-08-05 Thread W. eWatson
In my on-again-off-again experience with Python for 18 months, portability seems an issue. As an example, my inexperienced Python partner 30 miles away has gotten out of step somehow. I think by installing a different version of numpy than I use. I gave him a program we both use months ago, an

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

2010-08-05 Thread Philip Semanchuk
On Aug 5, 2010, at 8:55 PM, 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.__? Hi Wayne, FYI it's got nothing to do with IDLE, it's just a question of whether or no

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

2010-08-05 Thread W. eWatson
On 8/5/2010 6:23 PM, MRAB wrote: 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

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

2010-08-05 Thread W. eWatson
On 8/5/2010 6:13 PM, Steven D'Aprano wrote: 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 t

Re: defining, raising and catching exceptions

2010-08-05 Thread Steven D'Aprano
On Fri, 06 Aug 2010 01:37:17 +0100, MRAB wrote: > The correct way to create your own exceptions is to call the > superclass's __init__ method: > > > >>> class NetActiveError(RuntimeError): > ... def __init__(self, error): > ... RuntimeError.__init__(self, error) As given, that's po

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

2010-08-05 Thread Steven D'Aprano
On Thu, 05 Aug 2010 12:07:53 -0400, wheres pythonmonks wrote: > 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. Er, surely you can just move the cursor before you start typing??? -- Steven -- http://mail.python.org/mailman/lis

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

*** 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: 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,

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

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

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

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

  1   2   >