Re: postprocessing in os.walk

2009-10-13 Thread Ethan Furman
kj wrote: In Dave Angel writes: [snippetty snip] Why would you need a special hook when the os.walk() generator yields exactly once per directory? So whatever work you do on the list of files you get, you can then put the summary logic immediately after. I think you're missing the p

Re: setting variables in the local namespace

2009-10-13 Thread Mick Krippendorf
Hello. Chris Withers schrieb: > mname = model.__name__ > fname = mname+'_order' > value = request.GET.get('order') > if value: > request.session[fname]=value > else: > value = request.session.get( > fname, >

Re: speed up linecache.getline()

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 10:21:31 -0300, escribió: I am using linecache.getline, to access to a line in a long file. It s really fast, appx 4seconds, but I was just wandering if any of you, know either another way, or there is something that I can do to speed it up... thank you very much for y

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Ethan Furman
Buck wrote: [snip] Steven had the nicest workaround (with the location = __import__ ('__main__').__file__ trick), but none of them solve the problem of the OP: organization of runnable scripts. So far it's been required to place all runnable scripts directly above any used packages. The workaro

Re: setting variables in the local namespace

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 13:05:03 -0300, Chris Withers escribió: What I'd be looking for is something like: locals()[name]=value ...or, say: setattr(,name,value) Now, I got horribly flamed for daring to be so heretical as to suggest this might be a desirable thing in #python, so I thought I'

Re: postprocessing in os.walk

2009-10-13 Thread Dave Angel
Peter Otten wrote: kj wrote: In Dave Angel writes: kj wrote: Perl's directory tree traversal facility is provided by the function find of the File::Find module. This function accepts an optional callback, called postprocess, that gets invoked "just before leaving the curren

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Buck
On Oct 12, 3:34 pm, "Gabriel Genellina" wrote: > En Mon, 12 Oct 2009 15:24:34 -0300, Buck escribió: > > > On Oct 10, 9:44 am, "Gabriel Genellina" > > wrote: > >> The good thing is that, if the backend package is properly installed   > >> somewhere in the Python path ... it still works with no mo

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Buck
On Oct 12, 4:30 pm, Carl Banks wrote: > On Oct 12, 11:24 am, Buck wrote: > > > On Oct 10, 9:44 am, "Gabriel Genellina" > > wrote: > > > > The good thing is that, if the backend package is properly installed   > > > somewhere in the Python path ... it still works with no modifications. > > > I'd

Re: [OT] organizing your scripts, with plenty of re-use

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 03:48:00 -0300, Dennis Lee Bieber escribió: On Mon, 12 Oct 2009 16:36:58 -0700, Ethan Furman declaimed the following in gmane.comp.python.general: coffe table, you look in your car, etc, etc, and so forth. If you move a file in a package to somewhere else, and you don't

Re: efficient running median

2009-10-13 Thread Peter Otten
Janto Dreijer wrote: > I'm looking for code that will calculate the running median of a > sequence, efficiently. (I'm trying to subtract the running median from > a signal to correct for gradual drift). > > My naive attempt (taking the median of a sliding window) is > unfortunately too slow as my

Re: The rap against "while True:" loops

2009-10-13 Thread John Reid
Mensanator wrote: No, it's just that the OP was asking whether avoiding "while True" is considered Best Practice. How can you answer such a question without sounding dogmatic? I was just pointing out your style of programming seems inflexible. "Just another line that has to be interpreted l

setting variables in the local namespace

2009-10-13 Thread Chris Withers
Hi All, Say I have a piece of code like this: mname = model.__name__ fname = mname+'_order' value = request.GET.get('order') if value: request.session[fname]=value else: value = request.session.get( fname,

Re: Is pythonic version of scanf() or sscanf() planned?

2009-10-13 Thread Aahz
In article , ryniek90 wrote: > >But I remember that lambda function also was unwelcome in Python, but >finally it is and is doing well. So maybe someone, someday decide to >put in Python an alternative, really great implementation of scanf() ? How long have you been using Python? lambda has bee

Re: When to derive from object?

2009-10-13 Thread Matimus
On Oct 13, 8:02 am, Matimus wrote: > On Oct 13, 7:45 am, Igor Mikushkin wrote: > > > Hello all! > > > I'm a newbie to Python. > > Could you please say me when it is better to derive from "object" and > > when not? > > > Thanks, > > Igor > > The only reason to derive from 'object' is ... erm... t

efficient running median

2009-10-13 Thread Janto Dreijer
I'm looking for code that will calculate the running median of a sequence, efficiently. (I'm trying to subtract the running median from a signal to correct for gradual drift). My naive attempt (taking the median of a sliding window) is unfortunately too slow as my sliding windows are quite large (

Re: The rap against "while True:" loops

2009-10-13 Thread Mensanator
On Oct 13, 3:44�am, John Reid wrote: > Mensanator wrote: > >> Nothing wrong with a having a break IMHO. > > > My opinion is that there is everything wrong with > > having a break. I don't think I have ever used one, > > I write code that doesn't depend on that crutch. > > I guess its crutch-iness

Re: pickle's backward compatibility

2009-10-13 Thread M.-A. Lemburg
exar...@twistedmatrix.com wrote: > On 02:48 pm, m...@egenix.com wrote: >> exar...@twistedmatrix.com wrote: >>> On 03:17 pm, pengyu...@gmail.com wrote: Hi, If I define my own class and use pickle to serialize the objects in this class, will the serialized object be successfully r

Re: pickle's backward compatibility

2009-10-13 Thread exarkun
On 02:48 pm, m...@egenix.com wrote: exar...@twistedmatrix.com wrote: On 03:17 pm, pengyu...@gmail.com wrote: Hi, If I define my own class and use pickle to serialize the objects in this class, will the serialized object be successfully read in later version of python. What if I serialize (usi

Re: When to derive from object?

2009-10-13 Thread Matimus
On Oct 13, 7:45 am, Igor Mikushkin wrote: > Hello all! > > I'm a newbie to Python. > Could you please say me when it is better to derive from "object" and > when not? > > Thanks, > Igor The only reason to derive from 'object' is if there is some sort of weird side effect of using new style classe

Re: When to derive from object?

2009-10-13 Thread Bruno Desthuilliers
Igor Mikushkin a écrit : Hello all! I'm a newbie to Python. Welcome onboard Could you please say me when it is better to derive from "object" and when not? - When not : when using Python >= 3.0, or when already subclassing another class. - When : any other case !-) -- http://mail.pytho

When to derive from object?

2009-10-13 Thread Igor Mikushkin
Hello all! I'm a newbie to Python. Could you please say me when it is better to derive from "object" and when not? Thanks, Igor -- http://mail.python.org/mailman/listinfo/python-list

Re: pickle's backward compatibility

2009-10-13 Thread M.-A. Lemburg
exar...@twistedmatrix.com wrote: > On 03:17 pm, pengyu...@gmail.com wrote: >> Hi, >> >> If I define my own class and use pickle to serialize the objects in >> this class, will the serialized object be successfully read in later >> version of python. >> >> What if I serialize (using pickle) an objec

Re: os.chmod problem

2009-10-13 Thread Victor Subervi
Never mind. I just discovered that os.chmod requires 0755, not just 755. V On Tue, Oct 13, 2009 at 9:26 AM, Victor Subervi wrote: > Hi; > I have the following code: > > if 13 < x < 20: > y += 1 > w += 1 > try: > getpic = "getpic" + str(w

os.chmod problem

2009-10-13 Thread Victor Subervi
Hi; I have the following code: if 13 < x < 20: y += 1 w += 1 try: getpic = "getpic" + str(w) + ".py" try: os.remove(getpic) except: pass code = """#! /usr/bin/pytho

Input redirection with IDLE

2009-10-13 Thread candide
Hi Does IDLE (the default GUI avalaible with the standard distribution) support redirection from the standard input ? To be more precise, inside a Windows or Linux shell I may redirect input data from a text file to be executed by a python file. For instance suppose I have this python file # fo

Re: a=[1,2,3,4].reverse() - why "a" is None?

2009-10-13 Thread Simon Forman
On Mon, Oct 12, 2009 at 4:44 AM, Nadav Chernin wrote: > >        Chris Withers wrote: > >        ...becauase you were looking for: > >        reversed([1,2,3,4]) > > OK, but my question is generic. Why when I use object's function that > changed values of the object, I can't to get value of it on

Re: Cannot upload a good egg on pypi

2009-10-13 Thread Chris Withers
Luca Fabbri wrote: I've problems while using setuptools for getting an egg and upload it on pypi. The egg (in bdist_egg or sdist format) are always "corrupted" as far as a lot of files are not included in the zip, tar.gz or egg results. Looking at google it seems that this problem has been fixed

Re: Where to find pexpect

2009-10-13 Thread Jean-Michel Pichavant
Antoon Pardon wrote: I have been looking for pexpect. The links I find like http://pexpect.sourceforge.net all end up at http://www.noah.org/wiki/Pexpect which produces a 404 not found problem. Does someone know the current location? maybe they removed the distribution so you may use "subpr

Is somebody used Python in LabVIEW?

2009-10-13 Thread Nadav Chernin
Hi, I use Python as scripting tool in LabVIEW. I use lvpython.dll that include only built-in modules of python. But I need to use for example also urllib that is not included in lvpython.dll. How can I use it also? Thanks, Nadav -- http://mail.python.org/mailman/listinfo/python-list

Re: postprocessing in os.walk

2009-10-13 Thread Paul Rubin
kj writes: > I think you're missing the point. The hook in question has to be > called *immediately after* all the subtrees that are rooted in > subdirectories contained in the current directory have been visited > by os.walk. > > I'd love to see your "5 lines" for *that*. I'm having trouble un

speed up linecache.getline()

2009-10-13 Thread bbarbero
Hi Everyone!! I am using linecache.getline, to access to a line in a long file. It s really fast, appx 4seconds, but I was just wandering if any of you, know either another way, or there is something that I can do to speed it up... thank you very much for your help!! Regards, Bea

Re: postprocessing in os.walk

2009-10-13 Thread Peter Otten
kj wrote: > In Dave Angel > writes: > >>kj wrote: >>> Perl's directory tree traversal facility is provided by the function >>> find of the File::Find module. This function accepts an optional >>> callback, called postprocess, that gets invoked "just before leaving >>> the currently processed d

Cannot upload a good egg on pypi

2009-10-13 Thread Luca Fabbri
Hi all. I've problems while using setuptools for getting an egg and upload it on pypi. The egg (in bdist_egg or sdist format) are always "corrupted" as far as a lot of files are not included in the zip, tar.gz or egg results. Looking at google it seems that this problem has been fixed (related to

"undefined symbol: TLSv1_method" error when import psycopg2

2009-10-13 Thread 一首诗
I installed psycopg2 by "easy_install psycopg2" on CentOS 5.3, no error was reported, but when I tried "import psycopg2", I got : exceptions.ImportError: /usr/lib/python2.4/site-packages/ psycopg2-2.0.9-py2.4-linux-i686.egg/psycopg2/_psycopg.so: undefined symbol: TLSv1_method What might cause

Re: postprocessing in os.walk

2009-10-13 Thread kj
In Dave Angel writes: >kj wrote: >> Perl's directory tree traversal facility is provided by the function >> find of the File::Find module. This function accepts an optional >> callback, called postprocess, that gets invoked "just before leaving >> the currently processed directory." The docum

Re: How to run python script in emacs

2009-10-13 Thread rustom
On Sep 26, 8:54 pm, devilkin wrote: > I'm just starting learning python, and coding in emacs. I usually > split emacs window into two, coding in one, and run script in the > other, which is not very convenient. anyone can help me with it? is > there any tricks like emacs short cut? > > also pleas

Re: reifying indent and dedent into braces

2009-10-13 Thread rustom
On Oct 13, 12:45 pm, Steven D'Aprano wrote: > > Have you looked at the tokenize module? > > http://docs.python.org/library/tokenize.html Thanks Steven -- that was what I was looking for. -- http://mail.python.org/mailman/listinfo/python-list

Re: does anyone know how to use libjeg from within memory in python

2009-10-13 Thread Chris Colbert
My emails must not be making it to list... I posted a solutions about 10 minutes after I posted the questions. Thanks! On Tue, Oct 13, 2009 at 12:35 PM, Dave Angel wrote: > Chris Colbert wrote: >> >> Say I use python to talk to a wireless webcamera that delivers images >> via http requests. >> >

Re: does anyone know how to use libjeg from within memory in python

2009-10-13 Thread Dave Angel
Chris Colbert wrote: Say I use python to talk to a wireless webcamera that delivers images via http requests. I request an image and read it into a buffer, but the image is in jpeg format. I would like to convert this to a simple RGB format buffer to pass to numpy. Has anyone managed this using

Re: does anyone know how to use libjeg from within memory in python

2009-10-13 Thread Chris Colbert
Heh, for whatever reason, your post is dated earlier than my response, but wasn't here when I sent mine. But yeah, PIL worked. On Tue, Oct 13, 2009 at 12:04 PM, Stefan Behnel wrote: > Chris Colbert wrote: >> Say I use python to talk to a wireless webcamera that delivers images >> via http request

Re: does anyone know how to use libjeg from within memory in python

2009-10-13 Thread Chris Colbert
In answering my own question, this can be done trivially with PIL. Here is a self contained example: In [1]: import httplib In [2]: from PIL import ImageFile In [3]: import numpy as np In [4]: conn = httplib.HTTPConnection('www.therealstevencolbert.com') In [5]: conn.request('GET', '/dump/IMG

Re: does anyone know how to use libjeg from within memory in python

2009-10-13 Thread Stefan Behnel
Chris Colbert wrote: > Say I use python to talk to a wireless webcamera that delivers images > via http requests. > > I request an image and read it into a buffer, but the image is in jpeg format. > > I would like to convert this to a simple RGB format buffer to pass to > numpy. Has anyone manage

does anyone know how to use libjeg from within memory in python

2009-10-13 Thread Chris Colbert
Say I use python to talk to a wireless webcamera that delivers images via http requests. I request an image and read it into a buffer, but the image is in jpeg format. I would like to convert this to a simple RGB format buffer to pass to numpy. Has anyone managed this using libjpeg or any other l

RabbitMQ vs ApacheQpid (AMQP)

2009-10-13 Thread jacopo
Short question: I am considering two solutions for a distributed system: either RabbitMQ with py-amqplib or ApacheQpid with its own set of API. I wander is any of you would be able to compare the two. In particular, I would expect that since Apache comes with its own documented Python API this wou

Re: In python CGI, how to pass "hello" back to a javascript function as an argument at client side?

2009-10-13 Thread Piet van Oostrum
> zxo102 (z) wrote: >z> Hi everyone, >z> How can I pass a string generated from python cgi at server side >z> to a >z> javascript function as an argument at client side? >z> I want test.py to "return" a "hello" back so the javascript function >z> load takes "hello" as argument like lo

Re: Form Value Won't Post/Submit

2009-10-13 Thread Piet van Oostrum
> SuperMetroid (S) wrote: >S> The html code of the form, and my code are below. I can't get the >S> value to post/submit.. instead I get an error. Can anyone help? >S> HTML Code of Form: >S> >S> >S> >S> S> value='92dcd92a8bc16f73f330d118ae1ed891' /> >S> >S> Grant bad

Re: In python CGI, how to pass "hello" back to a javascript function as an argument at client side?

2009-10-13 Thread Bruno Desthuilliers
zxo102 a écrit : Hi everyone, How can I pass a string generated from python cgi at server side to a javascript function as an argument at client side? This is common HTTP / javascriot stuff - nothing related to Python. First learn about the HTTP protocol - something you obviously need if

Re: What do I do now?

2009-10-13 Thread n00m
I'm going to develop further my py. script for text detection and localization in raster images: http://funkybee.narod.ru/ Slow Doe... -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-13 Thread Grant Edwards
On 2009-10-12, Gabriel Genellina wrote: >> my_prissy_little_indicator_variable = true >> while (my_prissy_little_indicator_variable){ >> >> } >> isn't satisfying because it doesn't guard the with any >> assurance that the loop invariant will be true before you enter into >> that block of co

Re: An assessment of Tkinter and IDLE

2009-10-13 Thread Ben Finney
TerryP writes: > One thing you should also learn about me, is I do not deal in > absolutes. What, *never*? That's a pretty uncompromising position to h— I'll get my coat. -- \ “Smoking cures weight problems. Eventually.” —Steven Wright | `\

Re: Where to find pexpect

2009-10-13 Thread Javier Collado
Hello, Google is your friend: http://sourceforge.net/projects/pexpect/ http://sourceforge.net/projects/pexpect/files/pexpect/Release%202.3/pexpect-2.3.tar.gz/download Best regards, Javier 2009/10/13 Antoon Pardon : > I have been looking for pexpect. The links I find like > http://pexpect.sou

Re: Work around metaclass programming

2009-10-13 Thread Diez B. Roggisch
Zac Burns schrieb: I have a class called Signal which is a descriptor. It is a descriptor so that it can create BoundSignals, much like the way methods work. What I would like to do is to have the class be a descriptor when instantiated in what will be the locals of the class, but not a descripto

Re: It Doesn't Add Up!

2009-10-13 Thread Stephen Hansen
On Mon, Oct 12, 2009 at 11:33 AM, Victor Subervi wrote: > for row in data: > i += 1 > total = 0 > quantity = form.getfirst('order_' + str(i), '') > if quantity != '': > sql = 'select * from products p join %s c on p.ID=c.ID where > c.ID=%s;' % (client, str(i)) >

Form Value Won't Post/Submit

2009-10-13 Thread SuperMetroid
The html code of the form, and my code are below. I can't get the value to post/submit.. instead I get an error. Can anyone help? HTML Code of Form: Grant badge: My Code: opener = urllib.request.build_opener() cj = http.cookiejar.MozillaCookieJar() cj.load('C:/Users/Al

RE: How to run python script in emacs

2009-10-13 Thread Sells, Fred
Here is the .emacs file I place at c:\ on xp. I don't understand it and cannot explain it. It was developed by a few guys I worked with 20 years ago and still does the job. Probably quite obsolete by now, but if it ain't broke... In response to your "what do you mean" With the cursor in a python

twill unicode related

2009-10-13 Thread james27
hello im learning twill,but have some problem with unicode. whenever i use twill's follow function which emulate webbrowser link click function,it can work well with english link,but can't work with unicode. does anybody some know about this probelm? thank in advance follow is sample # -*- codi

Re: The rap against "while True:" loops

2009-10-13 Thread John Reid
Mensanator wrote: Nothing wrong with a having a break IMHO. My opinion is that there is everything wrong with having a break. I don't think I have ever used one, I write code that doesn't depend on that crutch. I guess its crutch-iness is in the eye of the beholder. You seem to have a dogmat

Where to find pexpect

2009-10-13 Thread Antoon Pardon
I have been looking for pexpect. The links I find like http://pexpect.sourceforge.net all end up at http://www.noah.org/wiki/Pexpect which produces a 404 not found problem. Does someone know the current location? -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list

Re: Still wrong architecture on Snow Leopard

2009-10-13 Thread Ned Deily
In article <89f50109-83f9-4c1e-8e0d-7f985b1c2...@xiao-yu.com>, Xiao Yu wrote: > I have Snow Leopard and followed 4.6.1 snapshot 20091010's reference > 3.4 instructions to configure both SIP and PyQt in i386. Everything > installed fine but when I open Python and tried to import ImageQt, I >

Re: reifying indent and dedent into braces

2009-10-13 Thread Steven D'Aprano
On Tue, 13 Oct 2009 12:35:13 +0530, Rustom Mody wrote: > At http://www.secnetix.de/olli/Python/block_indentation.hawk I find that > the python code > if foo: > ... if bar: > ... x = 42 > ... else: > ... print foo > ... > > has its indentation structure made explicit as > >

Still wrong architecture on Snow Leopard

2009-10-13 Thread Xiao Yu
Hi everyone, I have Snow Leopard and followed 4.6.1 snapshot 20091010's reference 3.4 instructions to configure both SIP and PyQt in i386. Everything installed fine but when I open Python and tried to import ImageQt, I get the following error: Traceback (most recent call last): File "",

Re: reifying indent and dedent into braces

2009-10-13 Thread Stefan Behnel
Rustom Mody wrote: > I am trying to generate some python code and its > indentation=structure is giving me a headache! Have you considered searching the web for "Python code generator"? Stefan -- http://mail.python.org/mailman/listinfo/python-list

reifying indent and dedent into braces

2009-10-13 Thread Rustom Mody
At http://www.secnetix.de/olli/Python/block_indentation.hawk I find that the python code >>> if foo: ... if bar: ... x = 42 ... else: ... print foo ... has its indentation structure made explicit as <:>[0] <:> [0, 4] <=> <42> [0, 4,

<    1   2