Re: Run on Startup

2009-03-18 Thread Gabriel Genellina
En Tue, 17 Mar 2009 00:16:53 -0200, MRAB escribió: Ian Mallett wrote: I'd like to make a program that automatically runs on startup (right after login). How should I do that? Put it in the folder: C:\Documents and Settings\\Start Menu\Programs\Startup Please don't do that, if you care

Re: Strange crash issue on Windows w/ PyGTK, Cairo...

2009-03-18 Thread bieffe62
On Mar 18, 6:20 am, CJ Kucera wrote: > Hello list! > > I'm having a strange issue, and I'm not entirely certain yet where > the actual problem is (ie, Python, PyGTK, or gtk+), but I figure I'll > start here.  Bear with me, this'll probably be a long explanation... > > I've been building an app whi

Re: How to do this in Python?

2009-03-18 Thread bieffe62
On Mar 18, 2:00 am, Jim Garrison wrote: >  I don't want "for line in f:" because binary > files don't necessarily have lines and I'm bulk processing > files potentially 100MB and larger.  Reading them one line > at a time would be highly inefficient. > > Thanks- Hide quoted text - > > - Show quot

Re: print - bug or feature - concatenated format strings in a print statement

2009-03-18 Thread Steven D'Aprano
On Tue, 17 Mar 2009 22:41:26 -0700, John Machin wrote: > On Mar 18, 4:19 pm, Matt Nordhoff wrote: >> The implicit string concatenation is actually done by the compiler; it >> isn't an operator at all. Look: >> >> >>> import dis >> >>> def f(): >> >> ...     return "foo" "bar" >> ...>>> dis.dis(f

Re: Run on Startup

2009-03-18 Thread James Matthews
You may also add it to the registry or make it a windows service. Both will startup. On Wed, Mar 18, 2009 at 8:09 AM, Gabriel Genellina wrote: > En Tue, 17 Mar 2009 00:16:53 -0200, MRAB > escribió: > >> Ian Mallett wrote: >> >>> I'd like to make a program that automatically runs on startup (rig

Python 2.6 + Pytz 2009a + Py2exe problem

2009-03-18 Thread Jeff Peck
I've recently upgraded to python 2.6 and I'm having trouble building an executable using the new Pytz package. The relevant section of setup.py is below. This was working under python 2.5 using an ancient version of pytz (2006p). setup( console = [dict(script = my_script.py')], optio

SOAPpy help needed

2009-03-18 Thread somemilk
Hi everyone. I have a PHP script which works and i need to write the same in Python but SOAPpy generates a slightly different request and i'm not sure how to fix it so the server likes it. The request generated by php script looks like this (removed http's from links): * * * 66742

2to3 does not fix FileType from types Module; no replacement ?

2009-03-18 Thread mkieverpy
Hello list, just tried the new 3.1a1 release and its 2to3 script on a simple program of mine. The program uses a type check recipe from activestate. The recipe uses 'types.FileType' which is no longer present in 'types' in 3.1a1. 2to3 does not fix and gives no warning. I found these comments in

Re: How to do this in Python?

2009-03-18 Thread Hrvoje Niksic
Luis Zarrabeitia writes: > One could use this: > > with open(filename, "rb") as f: > for buf in iter(lambda: f.read(1000),''): > do_something(buff) This is by far the most pythonic solution, it uses the standard 'for' loop, and clearly marks the sentinel value. lambda may look stra

Re: Python 3D CAD -- need collaborators, or just brave souls :)

2009-03-18 Thread Josh Dukes
> VNC style remote control of other seats of the same software so parts > can be discussed with ease over the phone etc. It seems like project verse would be really cool to have for this. http://verse.blender.org/ -- Josh Dukes MicroVu IT Department -- http://mail.python.org/mailman/listinfo/p

Re: packaging

2009-03-18 Thread Craig Allen
> andrew thanks andrew, good advice, I should probably use that throughout our code. btw, hope the world is treating you well, long time no see... -craig -- http://mail.python.org/mailman/listinfo/python-list

Re: array next pointer

2009-03-18 Thread Duncan Booth
Armin wrote: > Could you give an example of next() with a sentinel and describe its > use case please? I have a little trouble understanding what you guys > mean! It means you don't have to worry about next() throwing StopIteration. e.g. >>> def pairs(sequence, padding=None): sequenc

Re: Can python quickly display results like bash?

2009-03-18 Thread robert song
thank you, it works with -m trace. As to sh -x, it is used to expand the variables of command, and display it before executing. $ info bash * The `-x' (`xtrace') option displays commands other than simple commands when performing an execution trace (*note The Set Builtin::). 2009/

Re: How to do this in Python?

2009-03-18 Thread Tim Chase
def chunk_file(fp, chunksize=1): s = fp.read(chunksize) while s: yield s s = fp.read(chunksize) Ah. That's the Pythonesque way I was looking for. That's not pythonic unless you really do need to use chumk_file() in a lot of places (IMO, more than 3 or 4). If it only

Re: Python to Perl transalators

2009-03-18 Thread Andre Engels
On Wed, Mar 18, 2009 at 6:27 AM, wrote: > > -Original Message- > From: ch...@rebertia.com [mailto:ch...@rebertia.com] On Behalf Of Chris Rebert > Sent: Wednesday, March 18, 2009 10:53 AM > To: Raju, Abhinayaraj > Cc: python-list@python.org > Subject: Re: Python to Perl transalators > > 20

RE: Python to Perl transalators

2009-03-18 Thread Abhinayaraj . Raju
-Original Message- From: Andre Engels [mailto:andreeng...@gmail.com] Sent: Wednesday, March 18, 2009 3:53 PM To: Raju, Abhinayaraj Cc: python-list@python.org Subject: Re: Python to Perl transalators On Wed, Mar 18, 2009 at 6:27 AM, wrote: > > -Original Message- > From: ch...@re

RE: Python to Perl transalators

2009-03-18 Thread Andreas Tawn
> > 2009/3/17 : > >> Could anyone suggest whether there is any Python to Perl code convertors? > >> I found one on the net viz. Perthon. But it wasn't really helping out. > > > I am just a beginner learning both the languages. Wondered if I can have some > comparative understanding of both.

REDIRECT

2009-03-18 Thread gaeasiankom
Hi ! I'm new to Python. I'm having some difficulties to redirect the pages using python. Every time when I redirect, the URL changed accordingly. (Example : from http://localhost: to http://localhost/hello.py?name='J') What's the Python way of implementing this ? Can anyone help me out

objectoriented -?- functional

2009-03-18 Thread Walther Neuper
Hi, loving Java (oo) as well as SML (fun) I use to practice both of them separately. Now, with Python I would like to combine 'oo.extend()' with 'functional map': Python 2.4.4 (#2, Oct 22 2008, 19:52:44) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 Type "help", "copyright", "

Re: How to do this in Python?

2009-03-18 Thread Ulrich Eckhardt
Grant Edwards wrote: > with open(filename,"rb") as f: > while True: > buf = f.read(1) > if not buf: break > # do something The pattern with foo() as bar: # do something with bar is equivalent to bar = foo() if bar: # do something with bar except

Re: array next pointer

2009-03-18 Thread Hrvoje Niksic
Armin writes: >> Yep, that's what I meant, I forgot the parameter name. > > Could you give an example of next() with a sentinel and describe its > use case please? I have a little trouble understanding what you > guys mean! See the thread about reading the file in chunks. Instead of: while Tr

Re: 2to3 does not fix FileType from types Module; no replacement?

2009-03-18 Thread Benjamin Peterson
tlink.de> schrieb: > and I could not find a replacement for 'FileType'. > Has this been overlooked? > > Found this thread which does not mention FileType: > http://mail.python.org/pipermail/stdlib-sig/2008-April/thread.html#172 > > I guess I just did not see something simple. > Anyone with a hi

Re: objectoriented -?- functional

2009-03-18 Thread Francesco Guerrieri
On Wed, Mar 18, 2009 at 11:26 AM, Walther Neuper wrote: > Hi, > > loving Java (oo) as well as SML (fun) I use to practice both of them > separately. > Now, with Python I would like to combine 'oo.extend()' with 'functional > map': > > Python 2.4.4 (#2, Oct 22 2008, 19:52:44) > [GCC 4.1.2 20061115

split problem if the delimiter is inside the text limiter

2009-03-18 Thread rewonka
Hi, I had a problem, i would like to process a file into a PSQL, but in the file the delimiter char is ':' and i have the same charater inside the text field also. something like this: text = 1:23:34:"sample: text":" something" if I use text.split(':') it will be ['1', '23', '34', '"sample', 'text

Re: split problem if the delimiter is inside the text limiter

2009-03-18 Thread Tino Wildenhain
rewonka wrote: Hi, I had a problem, i would like to process a file into a PSQL, but in the file the delimiter char is ':' and i have the same charater inside the text field also. something like this: text = 1:23:34:"sample: text":" something" if I use text.split(':') it will be ['1', '23', '34',

Re: REDIRECT

2009-03-18 Thread Tino Wildenhain
gaeasian...@gmail.com wrote: Hi ! I'm new to Python. I'm having some difficulties to redirect the pages using python. Every time when I redirect, the URL changed accordingly. (Example : from http://localhost: to http://localhost/hello.py?name='J') What's the Python way of implementin

Re: split problem if the delimiter is inside the text limiter

2009-03-18 Thread Peter Otten
rewonka wrote: > I had a problem, i would like to process a file into a PSQL, but in > the file the delimiter char is ':' > and i have the same charater inside the text field also. > something like this: > text = 1:23:34:"sample: text":" something" > if I use text.split(':') > it will be ['1', '23

Creating 50K text files in python

2009-03-18 Thread venutaurus...@gmail.com
Hello all, I've an application where I need to create 50K files spread uniformly across 50 folders in python. The content can be the name of file itself repeated 10 times.I wrote a code using normal for loops but it is taking hours together for that. Can some one please share the code for

Re: REDIRECT

2009-03-18 Thread Jeremiah Dodds
On Wed, Mar 18, 2009 at 10:54 AM, wrote: > Hi ! > > I'm new to Python. I'm having some difficulties to redirect the pages > using python. Every time when I redirect, the URL changed accordingly. > > (Example : from http://localhost: to > http://localhost/hello.py?name='J

Re: objectoriented -?- functional

2009-03-18 Thread Peter Otten
Walther Neuper wrote: > loving Java (oo) Don't mind, weirder things have happened http://wiki.muenster.org/index.php/Schwan > as well as SML (fun) I use to practice both of them > separately. > Now, with Python I would like to combine 'oo.extend()' with 'functional > map': > > Python 2.4.4

Re: [python-list] Re: Strange crash issue on Windows w/ PyGTK, Cairo...

2009-03-18 Thread CJ Kucera
bieff...@gmail.com wrote: > It looks like some of the C extension you are using is causing a > segfault or similar in python > interpreter (or it could be a bug in the interpreter itself, but it is > a lot less likely). Okay... I assume by "C extension" you'd include the PyGTK stuff, right? (ie:

Re: Creating 50K text files in python

2009-03-18 Thread Peter Otten
venutaurus...@gmail.com wrote: > Hello all, > I've an application where I need to create 50K files spread > uniformly across 50 folders in python. The content can be the name of > file itself repeated 10 times.I wrote a code using normal for loops > but it is taking hours together for th

Re: Creating 50K text files in python

2009-03-18 Thread Tim Chase
I've an application where I need to create 50K files spread uniformly across 50 folders in python. The content can be the name of file itself repeated 10 times.I wrote a code using normal for loops but it is taking hours together for that. Can some one please share the code for it using

Re: Creating 50K text files in python

2009-03-18 Thread venutaurus...@gmail.com
On Mar 18, 6:16 pm, "venutaurus...@gmail.com" wrote: > Hello all, >           I've an application where I need to create 50K files spread > uniformly across 50 folders in python. The content can be the name of > file itself repeated 10 times.I wrote a code using normal for loops > but it is taking

Re: Mangle function name with decorator?

2009-03-18 Thread Adam
On Mar 17, 1:49 pm, Aaron Brady wrote: > You would need a unique attribute to look for on values in the > dictionary, which means you'd need to detect what functions you are > renaming; possibly by using a decorator to mark them.  (Untested:) > > class X( metaclass= M ): >   @mark( 'A' ) >   def

Re: Creating 50K text files in python

2009-03-18 Thread venutaurus...@gmail.com
On Mar 18, 6:35 pm, Peter Otten <__pete...@web.de> wrote: > venutaurus...@gmail.com wrote: > > Hello all, > >           I've an application where I need to create 50K files spread > > uniformly across 50 folders in python. The content can be the name of > > file itself repeated 10 times.I wrote a c

Re: Style formating of multiline query, advise

2009-03-18 Thread John Machin
On Mar 18, 11:25 pm, someone wrote: > Hi, > > what is good :) style for multiline queries to database? > Is that one ok? > query = """ SELECT * FROM ( >                    SELECT a.columna, a.columnb, a.iso >                       FROM all a >                       WHERE (a.name = LOWER(%s))  ) AS

Re: Creating 50K text files in python

2009-03-18 Thread Marco Mariani
venutaurus...@gmail.com wrote: for k in range (1,1001): ... k = k+1 Man, you have a trouble with loops, all over. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python to Perl transalators

2009-03-18 Thread Boris Borcic
Armin wrote: Why on earth would you want to? That'd be like translating Shakespeare into a bad rap song! lol, actually I would prefer a rap song over Shakespeare, so your analogy doesn't work there ;) Why, some people do prefer Perl over Python, so what's wrong with the analogy ? -- http

Re: Creating 50K text files in python

2009-03-18 Thread venutaurus...@gmail.com
On Mar 18, 6:58 pm, Marco Mariani wrote: > venutaurus...@gmail.com wrote: > >     for k in range (1,1001): >        ... > >         k = k+1 > > Man, you have a trouble with loops, all over. But the situation demands it.:-( I've to create 5 folders and 10 folders in each of them. Each folder again

Re: 2to3 does not fix FileType from types Module; no replacement?

2009-03-18 Thread John Roth
On Mar 18, 5:48 am, Benjamin Peterson wrote: >   tlink.de> schrieb: > > > and I could not find a replacement for 'FileType'. > > Has this been overlooked? > > > Found this thread which does not mention FileType: > >http://mail.python.org/pipermail/stdlib-sig/2008-April/thread.html#172 > > > I gues

Re: Creating 50K text files in python

2009-03-18 Thread Peter Otten
venutaurus...@gmail.com wrote: > On Mar 18, 6:35 pm, Peter Otten <__pete...@web.de> wrote: >> venutaurus...@gmail.com wrote: >> > Hello all, >> > I've an application where I need to create 50K files spread >> > uniformly across 50 folders in python. The content can be the name of >> > file itself

Re: Creating 50K text files in python

2009-03-18 Thread Gabriel Genellina
En Wed, 18 Mar 2009 11:40:26 -0200, venutaurus...@gmail.com escribió: On Mar 18, 6:16 pm, "venutaurus...@gmail.com" wrote:           I've an application where I need to create 50K files spread uniformly across 50 folders in python. The content can be the name of file itself repeated 10 time

Re: Creating 50K text files in python

2009-03-18 Thread Marco Mariani
venutaurus...@gmail.com wrote: for k in range (1,1001): ... k = k+1 Man, you have a trouble with loops, all over. But the situation demands it.:-( No. I mean, the for loops are wrong. Compare with the following and see why import os base = '/tmp/foo' for outer in x

Re: Creating 50K text files in python

2009-03-18 Thread John Machin
On Mar 19, 12:50 am, "venutaurus...@gmail.com" >         FName = "TextFile"+c+"_"+d+"_"+p+".txt" >         l =1 >         for l in range(1 , 11): >             os.system ("\"echo "+FName+" >> "+FName+"\"") >             l = l +1 That is not the most clear code that I've ever seen. Makeover time! o

Re: Creating 50K text files in python

2009-03-18 Thread Gabriel Genellina
En Wed, 18 Mar 2009 11:50:32 -0200, venutaurus...@gmail.com escribió: On Mar 18, 6:35 pm, Peter Otten <__pete...@web.de> wrote: venutaurus...@gmail.com wrote: > Hello all, >           I've an application where I need to create 50K files spread > uniformly across 50 folders in python. The con

Re: objectoriented -?- functional

2009-03-18 Thread Armin
On Wednesday 18 March 2009 10:19:41 Peter Otten wrote: > Walther Neuper wrote: > > loving Java (oo) > > Don't mind, weirder things have happened > > http://wiki.muenster.org/index.php/Schwan > LOL!! > > as well as SML (fun) I use to practice both of them > > separately. > > Now, with Python I wou

Re: Python to Perl transalators

2009-03-18 Thread Armin
On Wednesday 18 March 2009 11:01:00 Boris Borcic wrote: > Armin wrote: > >> > >> Why on earth would you want to? That'd be like translating Shakespeare > >> into a bad rap song! > >> > > > > lol, actually I would prefer a rap song over Shakespeare, so your analogy > > doesn't work there ;) > > Wh

Re: Mangle function name with decorator?

2009-03-18 Thread J. Cliff Dyer
You might be interested in redefining __getattribute__(self, attr) on your class. This could operate in conjunction with the hash tables (dictionaries) mentioned by andrew cooke. i.e. (untested code): class C(object): def __init__(self): self._get_table = {} self._post_table

Re: [python-list] Re: Strange crash issue on Windows w/ PyGTK, Cairo...

2009-03-18 Thread MRAB
CJ Kucera wrote: bieff...@gmail.com wrote: It looks like some of the C extension you are using is causing a segfault or similar in python interpreter (or it could be a bug in the interpreter itself, but it is a lot less likely). Okay... I assume by "C extension" you'd include the PyGTK stuff,

ANN: eGenix pyOpenSSL Distribution 0.8.1-0.9.8j now also for Mac OS X

2009-03-18 Thread eGenix Team: M.-A. Lemburg
ANNOUNCING eGenix.com pyOpenSSL Distribution Version 0.8.1-0.9.8j An easy to install and use repackaged distribution of the pyOpenSSL Python interfac

Re: Creating 50K text files in python

2009-03-18 Thread S Arrowsmith
venutaurus...@gmail.com wrote: >FName = "TextFile"+c+"_"+d+"_"+p+".txt" >l = 1 >for l in range(1 , 11): >os.system ("\"echo "+FName+" >> "+FName+"\"") >l = l +1 1. os.system spawns a new process, which on Windows (I'm guessing you're on Windows give

Re: Creating 50K text files in python

2009-03-18 Thread Laurent Rahuel
Hi, I don't know why you are forking shells using os.system. You should either use system commands to do the job or plain python, but mixing both should never be an option. Here is a plain portable python script (using the with statement. Your python should not be to old) from __future__

Re: Style formating of multiline query, advise

2009-03-18 Thread Tino Wildenhain
John Machin wrote: On Mar 18, 11:25 pm, someone wrote: Hi, what is good :) style for multiline queries to database? Is that one ok? query = """ SELECT * FROM ( SELECT a.columna, a.columnb, a.iso FROM all a WHERE (a.name = LOWER(%s)

Re: How to do this in Python?

2009-03-18 Thread Jim Garrison
Luis Zarrabeitia wrote: On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote: with open(filename, "rb") as f: for buf in iter(lambda: f.read(1000),''): do_something(buff) This is the most pythonic solution yet. Thanks to all the responders who took time to ponder this seemingly

Re: Mangle function name with decorator?

2009-03-18 Thread R. David Murray
> class foo_controller(Controller): > __metaclass__= ControllerMetaclass > def __init__(self, action, method = None): > self.action = action > self.method = method > > > def foo(self): > print "in foo()" > > @get_only > def foo(self): > print "

Re: How to do this in Python?

2009-03-18 Thread Mel
Jim Garrison wrote: > andrew cooke wrote: >> Jim Garrison wrote: >>> I'm an experienced C/Java/Perl developer learning Python. >>> What's the canonical Python way of implementing this pseudocode? [ ... ] >> but not doing much binary i/o >> myself, i suggest: >> >> with open(...) as f: >> while (

Re: Mangle function name with decorator?

2009-03-18 Thread Adam
On Mar 18, 10:33 am, "J. Cliff Dyer" wrote: > You might be interested in redefining __getattribute__(self, attr) on > your class.  This could operate in conjunction with the hash tables > (dictionaries) mentioned by andrew cooke.  i.e. (untested code): > > class C(object): >     def __init__(self)

Re: Style formating of multiline query, advise

2009-03-18 Thread someone
On Mar 18, 2:51 pm, John Machin wrote: > On Mar 18, 11:25 pm, someone wrote: > > > Hi, > > > what is good :) style for multiline queries to database? > > Is that one ok? > > query = """ SELECT * FROM ( > >                    SELECT a.columna, a.columnb, a.iso > >                       FROM all a

Re: 2to3 does not fix FileType from types Module; no replacement?

2009-03-18 Thread R. David Murray
John Roth wrote: > On Mar 18, 5:48 am, Benjamin Peterson wrote: > >   tlink.de> schrieb: > > > > > and I could not find a replacement for 'FileType'. > > > Has this been overlooked? > > > > > Found this thread which does not mention FileType: > > >http://mail.python.org/pipermail/stdlib-sig/2008-

smtplib problem with newly rebuilt Debian/lenny system

2009-03-18 Thread cassiope
A hard drive failure forced me to rebuild my main system. Just a few things haven't been restored; one of them is a python script which is used to email users of important events. In attempting to diagnose the cause, I tried directly executing the lines inside the python2.5 interpreter:

Re: Style formating of multiline query, advise

2009-03-18 Thread someone
On Mar 18, 4:04 pm, Tino Wildenhain wrote: > John Machin wrote: > > On Mar 18, 11:25 pm, someone wrote: > >> Hi, > > >> what is good :) style for multiline queries to database? > >> Is that one ok? > >> query = """ SELECT * FROM ( > >>                    SELECT a.columna, a.columnb, a.iso > >>  

Re: objectoriented -?- functional

2009-03-18 Thread Gerard Flanagan
Walther Neuper wrote: >>> def reverse_(list): ... """list.reverse() returns None; reverse_ returns the reversed list""" ... list.reverse() ... return list ... >>> ll = [[11, 'a'], [33, 'b']] >>> l = ll[:] # make a copy ! >>> l = map(reverse_, l[:]) # make a copy ? >>> ll.exte

Re: Python to Perl transalators

2009-03-18 Thread Nick Craig-Wood
Armin wrote: > On Wednesday 18 March 2009 11:01:00 Boris Borcic wrote: > > Armin wrote: > > >> > > >> Why on earth would you want to? That'd be like translating Shakespeare > > >> into a bad rap song! > > >> > > > > > > lol, actually I would prefer a rap song over Shakespeare, so your analogy >

Re: Mangle function name with decorator?

2009-03-18 Thread Adam
On Mar 18, 11:11 am, "R. David Murray" wrote: > I don't have any wisdom on the metaclass/decorator stuff, but what > about slightly reformulating the interface?  Instead of having the > programmer type, eg: > >     @GET >     def foo(self): pass > >     @POST >     def foo(self): pass > > have the

Re: Mangle function name with decorator?

2009-03-18 Thread Michele Simionato
On Mar 18, 4:18 pm, Adam wrote: > Hey, Cliff.  Thanks for sharing this idea.  Unfortunately, providing a > way to actually call the method with the mangled name is relatively > easy, and there are options there.  The real issue, to me, seems to be > finding a way to prevent Python from eating all

Re: Strange crash issue on Windows w/ PyGTK, Cairo...

2009-03-18 Thread bieffe62
On Mar 18, 2:33 pm, CJ Kucera wrote: > bieff...@gmail.com wrote: > > It looks like some of the C extension you are using is causing a > > segfault or similar in python > > interpreter (or it could be a bug in the interpreter itself, but it is > > a lot less likely). > > Okay...  I assume by "C ext

Re: SOAPpy help needed

2009-03-18 Thread Piet van Oostrum
> somemilk (D) wrote: >D> Hi everyone. >D> I have a PHP script which works and i need to write the same in Python >D> but SOAPpy generates a slightly different request and i'm not sure how >D> to fix it so the server likes it. >D> The request generated by php script looks like this (removed

Re: Mangle function name with decorator?

2009-03-18 Thread andrew cooke
Adam wrote: > Hey, Cliff. Thanks for sharing this idea. Unfortunately, providing a > way to actually call the method with the mangled name is relatively > easy, and there are options there. The real issue, to me, seems to be > finding a way to prevent Python from eating all but the last version

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread Jim Garrison
Jim Garrison wrote: Luis Zarrabeitia wrote: On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote: with open(filename, "rb") as f: for buf in iter(lambda: f.read(1000),''): do_something(buf) This is the most pythonic solution yet. Thanks to all the responders who took time to po

Re: array next pointer

2009-03-18 Thread R. David Murray
Duncan Booth wrote: > Armin wrote: > > > Could you give an example of next() with a sentinel and describe its > > use case please? I have a little trouble understanding what you guys > > mean! > > It means you don't have to worry about next() throwing StopIteration. > > e.g. > >>> def pairs

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread Andrii V. Mishkovskyi
On Wed, Mar 18, 2009 at 5:51 PM, Jim Garrison wrote: > Jim Garrison wrote: >> >> Luis Zarrabeitia wrote: >>> >>> On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote: >>> with open(filename, "rb") as f: >>>    for buf in iter(lambda: f.read(1000),''): >>>        do_something(buf) >> >> This is

Re: objectoriented -?- functional

2009-03-18 Thread Piet van Oostrum
> Walther Neuper (WN) wrote: >WN> Hi, >WN> loving Java (oo) as well as SML (fun) I use to practice both of them >WN> separately. >WN> Now, with Python I would like to combine 'oo.extend()' with 'functional >WN> map': >WN> Python 2.4.4 (#2, Oct 22 2008, 19:52:44) >WN> [GCC 4.1.2 20061115 (pre

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread Jim Garrison
Andrii V. Mishkovskyi wrote: Just before you start writing a PEP, take a look at `takewhile' function in `itertools' module. ;) OK, after reading the itertools docs I'm not sure how to use it in this context. takewhile() requires a sequence, and turning f.read(bufsize) into an iterable require

Re: Roulette wheel

2009-03-18 Thread Aahz
In article , Peter Otten <__pete...@web.de> wrote: >mattia wrote: >> >> cpop += [nchromosome1] + [nchromosome2] > >I'd write that as > >cpop.append(nchromosome1) >cpop.append(nchromosome2) > >thus avoiding the intermediate lists. You could also write it as cpop += [nchromosome1, nchromo

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread S Arrowsmith
Jim Garrison wrote: >It's a shame the iter(o,sentinel) builtin does the >comparison itself, instead of being defined as iter(callable,callable) >where the second argument implements the termination test and returns a >boolean. This would seem to add much more generality... is >it worthy of a PEP

Re: Style formating of multiline query, advise

2009-03-18 Thread Scott David Daniels
someone wrote: what is good :) style for multiline queries to database?... query = """ SELECT * FROM ( SELECT a.columna, a.columnb, a.iso FROM all a WHERE (a.name = LOWER(%s)) ) AS c JOIN other as b on c.gid = b.id

Re: Style formating of multiline query, advise

2009-03-18 Thread Steve Holden
Scott David Daniels wrote: > someone wrote: >> what is good :) style for multiline queries to database?... >> query = """ SELECT * FROM ( >>SELECT a.columna, a.columnb, a.iso >> FROM all a >> WHERE (a.name = LOWER(%s)) ) AS c >>

Re: Style formating of multiline query, advise

2009-03-18 Thread someone
On Mar 18, 5:56 pm, Scott David Daniels wrote: > someone wrote: > > what is good :) style for multiline queries to database?... > > query = """ SELECT * FROM ( > >                    SELECT a.columna, a.columnb, a.iso > >                       FROM all a > >                       WHERE (a.name = L

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread Jim Garrison
S Arrowsmith wrote: Jim Garrison wrote: It's a shame the iter(o,sentinel) builtin does the comparison itself, instead of being defined as iter(callable,callable) where the second argument implements the termination test and returns a boolean. This would seem to add much more generality... is

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread andrew cooke
have you looked in operators? that might avoid the need for a class. Jim Garrison wrote: > S Arrowsmith wrote: >> Jim Garrison wrote: >>> It's a shame the iter(o,sentinel) builtin does the >>> comparison itself, instead of being defined as iter(callable,callable) >>> where the second argument

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread andrew cooke
sorry, ignore that. hit send before thinking properly. > have you looked in operators? that might avoid the need for a class. -- http://mail.python.org/mailman/listinfo/python-list

Re: Mangle function name with decorator?

2009-03-18 Thread R. David Murray
Adam wrote: > David, would you believe that I just posted about this very idea, It > doesn't seem to have shown up yet, though. This idea works from the > perspective of being trivially easy to implement. I can easily write > a metaclass that looks in the namespace for methods with names that >

How complex is complex?

2009-03-18 Thread Kottiyath
When we say readability counts over complexity, how do we define what level of complexity is ok? For example: Say I have dict a = {'a': 2, 'c': 4, 'b': 3} I want to increment the values by 1 for all keys in the dictionary. So, should we do: >>> for key in a: ... a[key] = a[key] + 1 or is it Ok to

Openings for Python Programmer at CA

2009-03-18 Thread Aniket M
Hello , This is Aniket from Techclique, a New Jersey based software development and IT consulting firm providing top quality technical and software professionals on a permanent and contractual basis to Government and commercial customer including fortune 500 companies and most of states and federal

Disable automatic interning

2009-03-18 Thread George Sakkis
Is there a way to turn off (either globally or explicitly per instance) the automatic interning optimization that happens for small integers and strings (and perhaps other types) ? I tried several workarounds but nothing worked: >>> 'x' is 'x' True >>> 'x' is 'x'+'' True >>> 'x' is ''+'x' True >>>

Re: How complex is complex?

2009-03-18 Thread bearophileHUGS
Kottiyath: > How do we decide whether a level of complexity is Ok or not? I don't understand your question, but here are better ways to do what you do: >>> a = {'a': 2, 'c': 4, 'b': 3} >>> for k, v in a.iteritems(): ... a[k] = v + 1 ... >>> a {'a': 3, 'c': 5, 'b': 4} >>> b = dict((k, v+1) for k

Re: How complex is complex?

2009-03-18 Thread Casey Webster
On Mar 18, 1:30 pm, Kottiyath wrote: > When we say readability counts over complexity, how do we define what > level of complexity is ok? > For example: > Say I have dict a = {'a': 2, 'c': 4, 'b': 3} > I want to increment the values by 1 for all keys in the dictionary. > So, should we do:>>> for k

Re: How complex is complex?

2009-03-18 Thread George Sakkis
On Mar 18, 1:30 pm, Kottiyath wrote: > When we say readability counts over complexity, how do we define what > level of complexity is ok? > For example: > Say I have dict a = {'a': 2, 'c': 4, 'b': 3} > I want to increment the values by 1 for all keys in the dictionary. > So, should we do:>>> for

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread Luis Zarrabeitia
Quoting Jim Garrison : > Jim Garrison wrote: > > Luis Zarrabeitia wrote: > >> On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote: > >> with open(filename, "rb") as f: > >> for buf in iter(lambda: f.read(1000),''): > >> do_something(buf) > > > > This is the most pythonic solution

Disable automatic interning

2009-03-18 Thread R. David Murray
George Sakkis wrote: > Is there a way to turn off (either globally or explicitly per > instance) the automatic interning optimization that happens for small > integers and strings (and perhaps other types) ? I tried several > workarounds but nothing worked: No. It's an implementation detail. Wh

Re: Openings for Python Programmer at CA

2009-03-18 Thread Paul Rudin
Aniket M writes: > Note: Communication MUST be perfect!, Plus submit with 3 professional > references Irony :) -- http://mail.python.org/mailman/listinfo/python-list

Re: How complex is complex?

2009-03-18 Thread Paul McGuire
You realize of course that these two alternatives are not equivalent. The first does what your problem statement describes, for each key in a given dict, increments the corresponding value. The second creates an entirely new dict with the modified values. Even if you were to write the second one

Re: Run on Startup

2009-03-18 Thread Mike Driscoll
On Mar 18, 1:09 am, "Gabriel Genellina" wrote: > En Tue, 17 Mar 2009 00:16:53 -0200, MRAB   > escribió: > > > Ian Mallett wrote: > >>  I'd like to make a program that automatically runs on startup (right   > >> after login).  How should I do that? > > > Put it in the folder: > > > C:\Documents an

python equivalent of java technologies

2009-03-18 Thread markolopa
Hello, When comparing python and java with a colleague who is fan of java, she challenged me to find in python the equivalent to the following technologies. Could you please help telling if we have something equivalent in python or not and how they compare to the java solutions? - persistance fra

Re: Openings for Python Programmer at CA

2009-03-18 Thread Mike Driscoll
On Mar 18, 1:09 pm, Paul Rudin wrote: > Aniket M writes: > > Note: Communication MUST be perfect!, Plus submit with 3 professional > > references > > Irony :) I have yet to meet anyone with perfect communication. I think this is an "unfillable" position. Mike -- http://mail.python.org/mailman/l

Re: python equivalent of java technologies

2009-03-18 Thread Mike Driscoll
On Mar 18, 1:14 pm, markolopa wrote: > Hello, > > When comparing python and java with a colleague who is fan of java, > she challenged me to find in python the equivalent to the following > technologies. Could you please help telling if we have something > equivalent in python or not and how they

Re: Disable automatic interning

2009-03-18 Thread George Sakkis
On Mar 18, 2:13 pm, "R. David Murray" wrote: > George Sakkis wrote: > > Is there a way to turn off (either globally or explicitly per > > instance) the automatic interning optimization that happens for small > > integers and strings (and perhaps other types) ? I tried several > > workarounds but

Re: Run on Startup

2009-03-18 Thread Tim Wintle
On Wed, 2009-03-18 at 11:13 -0700, Mike Driscoll wrote: > On Mar 18, 1:09 am, "Gabriel Genellina" > > Any decent installer is able to register a program so it runs on startup > > (InnoSetup, by example). Anyway, if you want to it it yourself, > > see:http://msdn.microsoft.com/en-us/library/bb77

Re: split problem if the delimiter is inside the text limiter

2009-03-18 Thread rewonka
On márc. 18, 14:10, Peter Otten <__pete...@web.de> wrote: > rewonka wrote: > > I had a problem, i would like to process a file into a PSQL, but in > > the file the delimiter char is ':' > > and i have the same charater inside the text field also. > > something like this: > > text = 1:23:34:"sample:

  1   2   >