Re: An idiom for code generation with exec

2008-06-20 Thread eliben
On Jun 20, 2:44 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > eliben wrote: > > Additionally, I've found indentation to be a problem in such > > constructs. Is there a workable way to indent the code at the level of > > build_func, and not on column 0 ? > > exec"if 1:" + code.rstrip() > > Peter Why

Re: An idiom for code generation with exec

2008-06-20 Thread eliben
>d = {} > execcode in globals(), d > return d['foo'] > > My way: > > return function(compile(code, '', 'exec'), globals()) > With some help from the guys at IRC I came to realize your way doesn't do the same. It creates a function that, when called, creates 'foo' on globals(). This is not

Learning Python: Code critique please

2008-06-20 Thread macoovacany
Hello all, I'm trying to learn various programming languages (I did MATLAB at uni), and have decided to start with Python. The programming exercises are derived from Larry O'brien's http://www.knowing.net/ PermaLink,guid,f3b9ba36-848e-43f8-9caa-232ec216192d.aspx">15 Programming Exercises . First

Re: An idiom for code generation with exec

2008-06-20 Thread eliben
> So you are saying that for example "if do_reverse: data.reverse()" is > *much* slower than "data.reverse()" ? I would expect that checking the > truthness of a boolean would be negligible compared to the reverse > itself. Did you try converting all checks to identity comparisons with > None ? I m

Sqlite3 textfactory and user-defined function

2008-06-20 Thread jeff_d_harper
I've run into a problem with text encoding in the Sqlite3 module. I think it may be a bug. By default sqlite3 converts strings in the database from UTF-8 to unicode. This conversion can be controlled by changing the connection's text_factory. I have a database that stores strings in 8-bit ISO-8

Re: Weird local variables behaviors

2008-06-20 Thread Dan Bishop
On Jun 20, 7:32 pm, Matt Nordhoff <[EMAIL PROTECTED]> wrote: > Sebastjan Trepca wrote: > > Hey, > > > can someone please explain this behavior: > > > The code: > > > def test1(value=1): > >     def inner(): > >         print value > >     inner() > > > def test2(value=2): > >     def inner(): > >  

Re: ISO dict => xml converter

2008-06-20 Thread Waldemar Osuch
On Jun 20, 6:37 am, kj <[EMAIL PROTECTED]> wrote: > Hi.  Does anyone know of a module that will take a suitable Python > dictionary and return the corresponding XML structure? > > In Perl I use XML::Simple's handy XMLout function: > >   use XML::Simple 'XMLout'; >   my %h = ( 'Foo' => +{ >        

Re: Weird local variables behaviors

2008-06-20 Thread Matt Nordhoff
Sebastjan Trepca wrote: > Hey, > > can someone please explain this behavior: > > The code: > > def test1(value=1): > def inner(): > print value > inner() > > > def test2(value=2): > def inner(): > value = value > inner() > > test1() > test2() > > [EMAIL PROTEC

Re: sublassing as a verb

2008-06-20 Thread Carl Banks
On Jun 20, 4:34 pm, davidj411 <[EMAIL PROTECTED]> wrote: > docs on urllib module say this about the FancyUrlOpener: > "class FancyURLopener( ...) > > FancyURLopener subclasses URLopener providing default handling > for ..." > > does that mean the FancyURLopener is a subclass of URLopener? Yes. An

function factories and argument names

2008-06-20 Thread Chadrik
i know how to programmatically create python functions: module = __import__( '__main__') def factory( val ): def f( arg=val ): print arg, val f.__name__ = 'function%s' % x return f for x in [1,2,3,4]: func = factory( x ) setattr( module, func.__name__, fu

Weird local variables behaviors

2008-06-20 Thread Sebastjan Trepca
Hey, can someone please explain this behavior: The code: def test1(value=1): def inner(): print value inner() def test2(value=2): def inner(): value = value inner() test1() test2() [EMAIL PROTECTED] ~/dev/tests]$ python locals.py 1 Traceback (most recent call

[ANN] TPP Call for Papers, Volume 3 Issue 2

2008-06-20 Thread [EMAIL PROTECTED]
would like to call for papers, articles, opinion pieces and feedback to include in Volume 3, Issue 2 of The Python Papers. We would love to receive articles on Python for beginners and discussions about Python performance. Any article will be gratefully received, of course, so do not let the above

Re: optparse functionality missing

2008-06-20 Thread Robert Kern
Jeff Keasler wrote: Hi, optparse doesn't seem to have a pass-through capability for command line parameters/options that were not registered with add_option. I'm not the first person to complain about this. On Wed Mar 17 08:20:10 CET 2004, there's a thread titled "Perceived optparse shortc

optparse functionality missing

2008-06-20 Thread Jeff Keasler
Hi, optparse doesn't seem to have a pass-through capability for command line parameters/options that were not registered with add_option. I'm not the first person to complain about this. On Wed Mar 17 08:20:10 CET 2004, there's a thread titled "Perceived optparse shortcomings" where someone

Time-out for regular expressions...

2008-06-20 Thread [EMAIL PROTECTED]
I'm doing a lot of regular expressions these days. Sometimes when I'm crafting them I mess up, and make them too complicated. So that when my program runs, they take forever. (Maybe not literally forever---I abort the program after a few seconds.) What I'd like to have happen is every time I se

Re: How do I create a new Node using pulldom?

2008-06-20 Thread Paul Boddie
On 20 Jun, 22:17, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm using xml.dom.pulldom to parse through an XML file. I use > expandNode() to scrutinize certain blocks of it that I'm interested > in. Right. This is the thing which differentiates pulldom from traditional DOM implementations, w

Re: py2exe, PyQT, QtWebKit and jpeg problem

2008-06-20 Thread David Boddie
On Friday 20 June 2008 17:24, Phil Thompson wrote: > On Fri, 20 Jun 2008 08:04:57 -0700 (PDT), Carbonimax > <[EMAIL PROTECTED]> wrote: >> I have a problem with py2exe and QtWebKit : >> I make a program with a QtWebKit view. >> If I launch the .py directly, all images (jpg, png) are displayed but

Re: inheritance question...

2008-06-20 Thread Guilherme Polo
On Fri, Jun 20, 2008 at 6:19 PM, Hamish McKenzie <[EMAIL PROTECTED]> wrote: > > I have this class: > > class Vector(object): > TOL = 1e-5 > def __eq__( self, other, tolerance=TOL ): > print tolerance > > > shortened for clarity obviously. so I want to subclass this class like > s

inheritance question...

2008-06-20 Thread Hamish McKenzie
I have this class: class Vector(object): TOL = 1e-5 def __eq__( self, other, tolerance=TOL ): print tolerance shortened for clarity obviously. so I want to subclass this class like so: class BigVector(Vector) TOL = 100 for example if I was working with large vector

Re: An idiom for code generation with exec

2008-06-20 Thread [EMAIL PROTECTED]
On 20 juin, 21:44, eliben <[EMAIL PROTECTED]> wrote: > On Jun 20, 3:19 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > (snip) > > It's still not clear why the generic version is so slower, unless you > > extract only a few selected fields, not all of them. Can you post a > > sample of how you used

[ANN] Virtual Worlds Open Grid Protocols testing library in Python (pyogp)

2008-06-20 Thread Lawson English
A new open source project has been started by Linden Lab, makers of the Second Life™ virtual worlds, and the Second Life Architecture Working Group (AWG) to test LL's proposed virtual worlds Open Grid Protocols (OGP) that will allow any virtual world to support multi-world login, between-world

Re: Tkinter canvas drag/drop obstacle

2008-06-20 Thread Matimus
On Jun 20, 11:10 am, Matimus <[EMAIL PROTECTED]> wrote: > On Jun 20, 9:11 am, Peter Pearson <[EMAIL PROTECTED]> wrote: > > > Tkinter makes it very easy to drag jpeg images around on a > > canvas, but I would like to have a "target" change color when > > the cursor dragging an image passes over it.

Re: An idiom for code generation with exec

2008-06-20 Thread [EMAIL PROTECTED]
On 20 juin, 21:41, eliben <[EMAIL PROTECTED]> wrote: > > [1] except using compile to build a code object with the function's > > body, then instanciate a function object using this code, but I'm not > > sure whether it will buy you much more performance-wise. I'd personnaly > > prefer this because

Re: An idiom for code generation with exec

2008-06-20 Thread George Sakkis
On Jun 20, 3:44 pm, eliben <[EMAIL PROTECTED]> wrote: > On Jun 20, 3:19 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Jun 20, 8:03 am, eliben <[EMAIL PROTECTED]> wrote: > > > > On Jun 20, 9:17 am, Bruno Desthuilliers > > > [EMAIL PROTECTED]> wrote: > > > > eliben a écrit :> Hello, > >

Re: sublassing as a verb

2008-06-20 Thread [EMAIL PROTECTED]
On 20 juin, 22:34, davidj411 <[EMAIL PROTECTED]> wrote: > docs on urllib module say this about the FancyUrlOpener: > "class FancyURLopener( ...) > > FancyURLopener subclasses URLopener providing default handling > for ..." > > does that mean the FancyURLopener is a subclass of URLopener? You could

sublassing as a verb

2008-06-20 Thread davidj411
docs on urllib module say this about the FancyUrlOpener: "class FancyURLopener( ...) FancyURLopener subclasses URLopener providing default handling for ..." does that mean the FancyURLopener is a subclass of URLopener? -- http://mail.python.org/mailman/listinfo/python-list

How do I create a new Node using pulldom?

2008-06-20 Thread [EMAIL PROTECTED]
I'm using xml.dom.pulldom to parse through an XML file. I use expandNode() to scrutinize certain blocks of it that I'm interested in. Once I find a block of XML in the input file that I'm interested in, I need to add my own block . to the pulldom tree I'm building in memory. The documentati

Re: How to request data from a lazily-created tree structure ?

2008-06-20 Thread méchoui
On Jun 17, 10:54 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > Do you know if there is such XPath engine that can be applied to a DOM- > > like structure ? > > No. But I toyed with the idea to write one :) > > > One way would be to take an XPath engine from an existing XML engine > > (Eleme

Re: At long last...

2008-06-20 Thread Carl Banks
On Jun 19, 11:26 pm, Dan Bishop <[EMAIL PROTECTED]> wrote: > On Jun 19, 9:24 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > > On Jun 19, 10:17 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > > Carl Banks wrote: > > > > Tuples will have an index method in Python 2.6. > > > > > I promise I won't

Re: An idiom for code generation with exec

2008-06-20 Thread eliben
On Jun 20, 3:19 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Jun 20, 8:03 am, eliben <[EMAIL PROTECTED]> wrote: > > > > > On Jun 20, 9:17 am, Bruno Desthuilliers > > [EMAIL PROTECTED]> wrote: > > > eliben a écrit :> Hello, > > > > > In a Python program I'm writing I need to dynamically genera

Re: An idiom for code generation with exec

2008-06-20 Thread eliben
> [1] except using compile to build a code object with the function's > body, then instanciate a function object using this code, but I'm not > sure whether it will buy you much more performance-wise. I'd personnaly > prefer this because I find it more explicit and readable, but YMMV. > How is com

Re: Execute a script on a remote machine

2008-06-20 Thread Gerhard Häring
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 srinivasan srinivas wrote: > Is there any other way rather than communicating back to the caller? No, the remote PID isn't magically transferred via RSH. The remote script must communicate the PID back. Just writing it remotely as first line and on t

Re: An idiom for code generation with exec

2008-06-20 Thread eliben
> FWIW, when I had a similar challenge for dynamic coding, I just > generated a py file and then imported it. This technique was nice > because can also work with Pyrex or Psyco. > I guess this is not much different than using exec, at the conceptual level. exec is perhaps more suitable when you

Re: Python "is" behavior

2008-06-20 Thread Gary Herron
[EMAIL PROTECTED] wrote: On Jun 20, 9:38 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: On Fri, 20 Jun 2008 09:31:57 -0700 (PDT), [EMAIL PROTECTED] wrote: I am not certain why this is the case, but... a = 256 b = 256 a is b True a = 257 b = 257 a is b

Re: Simple Python class questions

2008-06-20 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, Lie <[EMAIL PROTECTED]> wrote: > On Jun 19, 7:21 pm, Ulrich Eckhardt <[EMAIL PROTECTED]> wrote: > > John Dann wrote: > > > Let's say I define the class in a module called comms.py. The class > > > isn't really going to inherit from any other class (except presumab

Re: ISO dict => xml converter

2008-06-20 Thread Paddy
On Jun 20, 1:37 pm, kj <[EMAIL PROTECTED]> wrote: > Hi.  Does anyone know of a module that will take a suitable Python > dictionary and return the corresponding XML structure? > > In Perl I use XML::Simple's handy XMLout function: > >   use XML::Simple 'XMLout'; >   my %h = ( 'Foo' => +{ >        

Re: Tkinter canvas drag/drop obstacle

2008-06-20 Thread Matimus
On Jun 20, 9:11 am, Peter Pearson <[EMAIL PROTECTED]> wrote: > Tkinter makes it very easy to drag jpeg images around on a > canvas, but I would like to have a "target" change color when > the cursor dragging an image passes over it.  I seem to be > blocked by the fact that the callbacks that might

how to export functions by name for ctype

2008-06-20 Thread rych
I'm on Windows with VS2005 testing ctypes on a very simple dll I create a test.dll project which exports a function fntest(). I don't touch anything in the autogenerated source and build it. I can load the dll but can't access the function by its name fntest. Only by ordinal number or calling getat

Re: Execute a script on a remote machine

2008-06-20 Thread srinivasan srinivas
This is ok. Is there any other way to find it out? Thanks, Srini - Original Message From: Gerhard Häring <[EMAIL PROTECTED]> To: python-list@python.org Sent: Friday, 20 June, 2008 10:03:30 PM Subject: Re: Execute a script on a remote machine srinivasan srinivas wrote: > Hi, > My require

Re: How do i : Python Threads + KeyboardInterrupt exception

2008-06-20 Thread Rhamphoryncus
On Jun 19, 11:09 pm, Brendon Costa <[EMAIL PROTECTED]> wrote: > > If only the main thread can receive KeyboardInterrupt, is there any > > reason why you couldn't move the functionality of the Read thread into > > the main thread? It looks like it's not doing any work, just waiting > > for the Proc

need to parse html to microsoft access table

2008-06-20 Thread Ahmed, Shakir
I need help to parse html file into Microsoft Access database table. Right now I could parse it in a csv file but the way it is parsing is not that I want and I could not import the list into access table as the information is parsing one after another and it is not a row column format. Any

Re: Python "is" behavior

2008-06-20 Thread Jean-Paul Calderone
On Fri, 20 Jun 2008 10:07:56 -0700 (PDT), George Sakkis <[EMAIL PROTECTED]> wrote: On Jun 20, 12:45 pm, [EMAIL PROTECTED] wrote: On Jun 20, 9:42 am, George Sakkis <[EMAIL PROTECTED]> wrote: > On Jun 20, 12:31 pm, [EMAIL PROTECTED] wrote: > > I am not certain why this is the case, but... >

Re: Python "is" behavior

2008-06-20 Thread George Sakkis
On Jun 20, 12:45 pm, [EMAIL PROTECTED] wrote: > On Jun 20, 9:42 am, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Jun 20, 12:31 pm, [EMAIL PROTECTED] wrote: > > > > I am not certain why this is the case, but... > > > > >>> a = 256 > > > >>> b = 256 > > > >>> a is b > > > > True > > > > >>>

Re: An idiom for code generation with exec

2008-06-20 Thread Dan Yamins
On Fri, Jun 20, 2008 at 3:17 AM, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: Just to make things clear: you do know that you can dynamically build > functions without exec, do you ? Actually, I don't know how to do this, but would like to. Can you point me to a place where I can read more a

Re: Simple and safe evaluator

2008-06-20 Thread bvdp
Aahz wrote: In article <[EMAIL PROTECTED]>, Simon Forman <[EMAIL PROTECTED]> wrote: FWIW, I got around to implementing a function that checks if a string is safe to evaluate (that it consists only of numbers, operators, and "(" and ")"). Here it is. :) What's safe about "1000 ** 1000

Re: Python "is" behavior

2008-06-20 Thread michalis . avraam
On Jun 20, 9:42 am, George Sakkis <[EMAIL PROTECTED]> wrote: > On Jun 20, 12:31 pm, [EMAIL PROTECTED] wrote: > > > > > I am not certain why this is the case, but... > > > >>> a = 256 > > >>> b = 256 > > >>> a is b > > > True > > > >>> a = 257 > > >>> b = 257 > > >>> a is b > > > False > > > Can any

Re: Python "is" behavior

2008-06-20 Thread michalis . avraam
On Jun 20, 9:38 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On Fri, 20 Jun 2008 09:31:57 -0700 (PDT), [EMAIL PROTECTED] wrote: > >I am not certain why this is the case, but... > > a = 256 > b = 256 > a is b > >True > > a = 257 > b = 257 > a is b > >False > > >

Re: Python "is" behavior

2008-06-20 Thread George Sakkis
On Jun 20, 12:31 pm, [EMAIL PROTECTED] wrote: > I am not certain why this is the case, but... > > >>> a = 256 > >>> b = 256 > >>> a is b > > True > > >>> a = 257 > >>> b = 257 > >>> a is b > > False > > Can anyone explain this further? Why does it happen? 8-bit integer > differences? No, implement

Re: Tkinter canvas drag/drop obstacle

2008-06-20 Thread Guilherme Polo
On Fri, Jun 20, 2008 at 1:11 PM, Peter Pearson <[EMAIL PROTECTED]> wrote: > Tkinter makes it very easy to drag jpeg images around on a > canvas, but I would like to have a "target" change color when > the cursor dragging an image passes over it. I seem to be > blocked by the fact that the callback

Re: Python "is" behavior

2008-06-20 Thread Jean-Paul Calderone
On Fri, 20 Jun 2008 09:31:57 -0700 (PDT), [EMAIL PROTECTED] wrote: I am not certain why this is the case, but... a = 256 b = 256 a is b True a = 257 b = 257 a is b False Can anyone explain this further? Why does it happen? 8-bit integer differences? http://mail.python.org/pipermail/pytho

Re: py2exe, PyQT, QtWebKit and jpeg problem

2008-06-20 Thread Phil Thompson
On Fri, 20 Jun 2008 08:04:57 -0700 (PDT), Carbonimax <[EMAIL PROTECTED]> wrote: > hello > > I have a problem with py2exe and QtWebKit : > I make a program with a QtWebKit view. > If I launch the .py directly, all images (jpg, png) are displayed but > if I compile it with py2exe I have only png ima

Re: Named tuples and projection

2008-06-20 Thread Giuseppe Ottaviano
[snip] Provided you don't change the order of the items in the tuple, you can just use slicing: a, b = f()[ : 2] Yes, this is what you would normally do with tuples. But i find this syntax very implicit and awkward. Also, you cannot skip elements, so you often end up with things like a,

Python "is" behavior

2008-06-20 Thread michalis . avraam
I am not certain why this is the case, but... >>> a = 256 >>> b = 256 >>> a is b True >>> a = 257 >>> b = 257 >>> a is b False Can anyone explain this further? Why does it happen? 8-bit integer differences? -- http://mail.python.org/mailman/listinfo/python-list

Re: Execute a script on a remote machine

2008-06-20 Thread Gerhard Häring
srinivasan srinivas wrote: Hi, My requirement is i have to execute a python script on a remote machine as a subprocess from a python script and to get the subprocess pid of the process running the script. Is there anyway to do that?? I have used subprocess.popen() method to do that. I have done

Tkinter canvas drag/drop obstacle

2008-06-20 Thread Peter Pearson
Tkinter makes it very easy to drag jpeg images around on a canvas, but I would like to have a "target" change color when the cursor dragging an image passes over it. I seem to be blocked by the fact that the callbacks that might tell the target that the mouse has entered it (, , even ) aren't call

Re: An idiom for code generation with exec

2008-06-20 Thread Bruno Desthuilliers
eliben a écrit : On Jun 20, 9:17 am, Bruno Desthuilliers wrote: eliben a écrit :> Hello, In a Python program I'm writing I need to dynamically generate functions[*] (snip) [*] I know that each time a code generation question comes up people suggest that there's a better way to achieve this

Re: images on the web

2008-06-20 Thread chris
On Jun 20, 1:52 am, Michael Ströder <[EMAIL PROTECTED]> wrote: > Matt Nordhoff wrote: > > Matt Nordhoff wrote: > >> You could use data: URIs [1]. > > >> For example, a 43-byte single pixel GIF becomes this URI: > > >> > > >> They don't have universal browser support, but that might not be a > >> p

Re: Simple Python class questions

2008-06-20 Thread Lie
On Jun 19, 10:49 pm, Ulrich Eckhardt <[EMAIL PROTECTED]> wrote: > Lie wrote: > > I think it's not that hard to see that it's just a pseudo code > > "...in comms.py I have: ..." actually explicitly says that it is actual code > from a file. > > *shrug* > > Uli > I'm not sure how you think saying 'i

Re: converting a text file to image

2008-06-20 Thread Larry Bates
jimgardener wrote: i am looking for python code to convert a textfile(.txt) to an image(preferrably Tiff).I believe it involves some scanning and conversion using some font table and probably compression using huffman encoding..is there an open source code doing this?can someone give a pointer?

py2exe, PyQT, QtWebKit and jpeg problem

2008-06-20 Thread Carbonimax
hello I have a problem with py2exe and QtWebKit : I make a program with a QtWebKit view. If I launch the .py directly, all images (jpg, png) are displayed but if I compile it with py2exe I have only png images. No jpg ! No error message, nothing. Have you a solution ? Thank you. -- http://mail.py

Re: Named tuples and projection

2008-06-20 Thread MRAB
On Jun 20, 9:38 am, Giuseppe Ottaviano <[EMAIL PROTECTED]> wrote: > I found the namedtuple very convenient for rapid prototyping code, for   > functions that have to return a number of results that could grow as   > the code evolves. They are more elegant than dicts, and I don't have   > to create

Re: Accent character problem

2008-06-20 Thread Diez B. Roggisch
Sallu schrieb: Hi all and one i wrote this script, working fine without fail( just run it) import re value='This is Praveen' print value #value = 'riché gerry' #words=str(value.split()).strip('[]').replace(', ', '') ( here i tried to convert in to list and then back to string) #print words richr

Re: Strange re problem

2008-06-20 Thread Paul McGuire
On Jun 20, 6:01 am, TYR <[EMAIL PROTECTED]> wrote: > OK, this ought to be simple. I'm parsing a large text file (originally > a database dump) in order to process the contents back into a SQLite3 > database. The data looks like this: > > 'AAA','PF',-17.4167,-145.5,'Anaa, French Polynesia','

Re: py2exe & application add-ons

2008-06-20 Thread Alex Gusarov
Thanks everybody, yes, I use 'exec' for files. And "freeze" modules - thanks too, I almost forgot this opportunity. -- Best regards, Alex Gusarov -- http://mail.python.org/mailman/listinfo/python-list

Re: Accent character problem

2008-06-20 Thread Mark Tolonen
"Sallu" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi all and one i wrote this script, working fine without fail( just run it) import re value='This is Praveen' print value #value = 'riché gerry' #words=str(value.split()).strip('[]').replace(', ', '') ( here i tried to convert

Re: An idiom for code generation with exec

2008-06-20 Thread Raymond Hettinger
On Jun 20, 5:03 am, eliben <[EMAIL PROTECTED]> wrote: > I've rewritten it using a dynamically generated procedure > for each field, that does hard coded access to its data. For example: > > def get_counter(packet): >   data = packet[2:6] >   data.reverse() >   return data > > This gave me a huge sp

Re: An idiom for code generation with exec

2008-06-20 Thread George Sakkis
On Jun 20, 8:03 am, eliben <[EMAIL PROTECTED]> wrote: > On Jun 20, 9:17 am, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote: > > eliben a écrit :> Hello, > > > > In a Python program I'm writing I need to dynamically generate > > > functions[*] > > > (snip) > > > > [*] I know that each time a code g

Re: regex \b behaviour in python

2008-06-20 Thread Walter Cruz
> I'm surprised that splitting on \b doesn't work as expected, so it > might be that re.split has been defined only to split on one or more > characters. Is it something that should it be 'fixed'? Thats's my main doubt: is this a bug or not? []'s - Walter -- http://mail.python.org/mailman/listinf

Re: pyinotify issue

2008-06-20 Thread Sebastian "lunar" Wiesner
AndreH <[EMAIL PROTECTED]>: > On Jun 17, 12:11 pm, AndreH <[EMAIL PROTECTED]> wrote: >> On Jun 13, 3:39 pm, AndreH <[EMAIL PROTECTED]> wrote: >> >> >> >> > Good day, >> >> > I just installed pyinotify on my gentoo box. >> >> > When I test the library through "pyinotify.pv -v /tmp" under root, >> >

Re: ISO dict => xml converter

2008-06-20 Thread Stefan Behnel
kj wrote: > Hi. Does anyone know of a module that will take a suitable Python > dictionary and return the corresponding XML structure? > > In Perl I use XML::Simple's handy XMLout function: > > use XML::Simple 'XMLout'; > my %h = ( 'Foo' => +{ > 'Bar' => +{ >

Accent character problem

2008-06-20 Thread Sallu
Hi all and one i wrote this script, working fine without fail( just run it) import re value='This is Praveen' print value #value = 'riché gerry' #words=str(value.split()).strip('[]').replace(', ', '') ( here i tried to convert in to list and then back to string) #print words richre=re.compile(r'[a

Re: An idiom for code generation with exec

2008-06-20 Thread Peter Otten
eliben wrote: > Additionally, I've found indentation to be a problem in such > constructs. Is there a workable way to indent the code at the level of > build_func, and not on column 0 ? exec "if 1:" + code.rstrip() Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange re problem

2008-06-20 Thread John Machin
On Jun 20, 10:33 pm, TYR <[EMAIL PROTECTED]> wrote: > >How do you propose to parse that string into a "set of values"? Can > >you rely there being data commas only in the 5th field, or do you need > >a general solution? What if (as Peter remarked) there is a ';' in the > >data? What if there's a "

ISO dict => xml converter

2008-06-20 Thread kj
Hi. Does anyone know of a module that will take a suitable Python dictionary and return the corresponding XML structure? In Perl I use XML::Simple's handy XMLout function: use XML::Simple 'XMLout'; my %h = ( 'Foo' => +{ 'Bar' => +{

Re: Strange re problem

2008-06-20 Thread TYR
>How do you propose to parse that string into a "set of values"? Can >you rely there being data commas only in the 5th field, or do you need >a general solution? What if (as Peter remarked) there is a ';' in the >data? What if there's a "'" in the data (think O'Hare)? My plan was to be pointlessl

Re: Why no output from xml.dom.ext.PrettyPrint?

2008-06-20 Thread kj
In <[EMAIL PROTECTED]> John Machin <[EMAIL PROTECTED]> writes: >On Jun 20, 7:17 am, kj <[EMAIL PROTECTED]> wrote: >> OK, the following should work but doesn't, and I can't figure out >> why: >> >> >>> from xml.marshal.generic import dumps >> >>> dumps( ( 1, 2.0, 'foo', [3,4,5] ) ) >> >> '> version

Re: Noob: finding my way around the docs...

2008-06-20 Thread kj
In <[EMAIL PROTECTED]> Matimus <[EMAIL PROTECTED]> writes: >If you are in the interpreter and you type: help(foo.bar.baz) you get >the embeded documentation. >I usually go straight to the `global module index` http://docs.python.org/m= >odindex.html Thanks! kynn -- NOTE: In my address everythi

Re: Pyparsing performance boost using Python 2.6b1

2008-06-20 Thread John Machin
On Jun 19, 8:40 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > I just ran my pyparsing unit tests with the latest Python 2.6b1 > (labeled internally as Python 2.6a3 - ???), Hi, Paul. If it says 2.6a3, that's what it is. Look at the thread of replies to Barry Warsaw's announcement of 2.6b1 ... [from

Re: Simple Python class questions

2008-06-20 Thread Duncan Booth
John Dann <[EMAIL PROTECTED]> wrote: > Yes I was wondering about that, but I wasn't clear about when 'body' > code (ie not contained within a def block) in the module might run > under Python. So it seemed to be safer to place the import statement > inside the 'constructor' to get the earliest war

Re: Strange re problem

2008-06-20 Thread John Machin
On Jun 20, 9:01 pm, TYR <[EMAIL PROTECTED]> wrote: > OK, this ought to be simple. I'm parsing a large text file (originally > a database dump) in order to process the contents back into a SQLite3 > database. The data looks like this: > > 'AAA','PF',-17.4167,-145.5,'Anaa, French Polynesia','

Execute a script on a remote machine

2008-06-20 Thread srinivasan srinivas
Hi, My requirement is i have to execute a python script on a remote machine as a subprocess from a python script and to get the subprocess pid of the process running the script. Is there anyway to do that?? I have used subprocess.popen() method to do that. I have done as following: executable = '

Re: An idiom for code generation with exec

2008-06-20 Thread eliben
On Jun 20, 9:17 am, Bruno Desthuilliers wrote: > eliben a écrit :> Hello, > > > In a Python program I'm writing I need to dynamically generate > > functions[*] > > (snip) > > > [*] I know that each time a code generation question comes up people > > suggest that there's a better way to achieve thi

Re: Simple Python class questions

2008-06-20 Thread cokofreedom
> > Yes I was wondering about that, but I wasn't clear about when 'body' > code (ie not contained within a def block) in the module might run > under Python. So it seemed to be safer to place the import statement > inside the 'constructor' to get the earliest warning of non-visibility > of pyserial

Re: Simple Python class questions

2008-06-20 Thread John Dann
Many thanks for the further comments: On Thu, 19 Jun 2008 21:24:31 -0400, Terry Reedy <[EMAIL PROTECTED]> wrote: >> def __init__(self): >> Try >> Import serial # the pyserial library >The import should be at module level. You only want to do it once, not

Re: Strange re problem

2008-06-20 Thread Mel
TYR wrote: > OK, this ought to be simple. I'm parsing a large text file (originally > a database dump) in order to process the contents back into a SQLite3 > database. The data looks like this: > > 'AAA','PF',-17.4167,-145.5,'Anaa, French Polynesia','Pacific/ > Tahiti','Anaa';'AAB','AU',-

Re: Strange re problem

2008-06-20 Thread Peter Otten
TYR wrote: > OK, this ought to be simple. I'm parsing a large text file (originally > a database dump) in order to process the contents back into a SQLite3 > database. The data looks like this: > > 'AAA','PF',-17.4167,-145.5,'Anaa, French Polynesia','Pacific/ > Tahiti','Anaa';'AAB','AU',-

Re: Pyparsing performance boost using Python 2.6b1

2008-06-20 Thread dwahli
On Jun 19, 12:40 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > I just ran my pyparsing unit tests with the latest Python 2.6b1 > (labeled internally as Python 2.6a3 - ???), and the current 1.5.0 > version of pyparsing runs with no warnings or regressions. > > I was pleasantly surprised by the impro

Re: Pattern Matching Over Python Lists

2008-06-20 Thread MRAB
On Jun 20, 1:45 am, Chris <[EMAIL PROTECTED]> wrote: > On Jun 17, 1:09 pm, [EMAIL PROTECTED] wrote: > > > Kirk Strauser: > > > > Hint: recursion.  Your general algorithm will be something like: > > > Another solution is to use a better (different) language, that has > > built-in pattern matching, o

Strange re problem

2008-06-20 Thread TYR
OK, this ought to be simple. I'm parsing a large text file (originally a database dump) in order to process the contents back into a SQLite3 database. The data looks like this: 'AAA','PF',-17.4167,-145.5,'Anaa, French Polynesia','Pacific/ Tahiti','Anaa';'AAB','AU',-26.75,141,'Arrabury, Que

Re: converting a text file to image

2008-06-20 Thread dwahli
On Jun 20, 9:15 am, jimgardener <[EMAIL PROTECTED]> wrote: > i am looking for python code to convert a textfile(.txt) to an > image(preferrably Tiff).I believe it involves some scanning  and > conversion using some font table and probably compression using > huffman encoding..is there an open sourc

Managing large python/c++ project

2008-06-20 Thread mathieu
Hi there, I am currently involved in managing a large python/c++ project (using swig to automagically wrap c++ code to python). So far my current experience was that python was a second class citizen and extremely little python code was written and everything seemed to work. Now this is the c

Named tuples and projection

2008-06-20 Thread Giuseppe Ottaviano
I found the namedtuple very convenient for rapid prototyping code, for functions that have to return a number of results that could grow as the code evolves. They are more elegant than dicts, and I don't have to create a new explicit class. Unfortunately in this situation they lose the conv

Earn 25 US$ in just 5 mins . . .

2008-06-20 Thread sweta
Earn 25 US$ in just 5 mins . . . You can earn 25 US$ in just 5mins from now, please follow the simple steps: It's absolutely free to join. Step 01 CLICK HERE http://www.awsurveys.com/HomeMain.cfm?RefID=ad125 A page will open Step 02 Click on "Create a Free Account" Step 03 Fill up the details a

Re: advanced listcomprehenions?

2008-06-20 Thread Ivan Illarionov
On 20 июн, 11:31, Duncan Booth <[EMAIL PROTECTED]> wrote: > Terry Reedy <[EMAIL PROTECTED]> wrote: > >> [['Fizz', 'Buzz', 'FizzBuzz', str(i)][62/(pow(i, 4, 15) + 1)%4] for i > >> in xrange(1, 101)] > > > These make the lookup table variable, so it has to be recalculated for > > each i. > > So what?

Re: Regular expression

2008-06-20 Thread Soltys
Duncan Booth pisze: Sallu <[EMAIL PROTECTED]> wrote: string = 'riché' ... unicode(string)).encode('ASCII', 'ignore') ... Output : sys:1: DeprecationWarning: Non-ASCII character '\xc3' in file regu.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for detai

Re: don't make it worse! - was Re: SPAM

2008-06-20 Thread bryan rasmussen
I guess it didn't because I was reading through Google Mail, and it wasn't filtered. Best Regards, Bryan Rasmussen On Fri, Jun 20, 2008 at 9:42 AM, Aspersieman <[EMAIL PROTECTED]> wrote: > Michael Torrie wrote: > > Aspersieman wrote: > > > SPAM > > > Obviously. Please refrain from replying to th

Re: Wierd Test Failure

2008-06-20 Thread Peter Otten
J-Burns wrote: > Hello. Im using doctests to check the functions that ive made. Wat i > dnt understand is that it gives me a fialure even though the expected > and got values are the same. Check this out: > > ** > File "C:\Python

Re: don't make it worse! - was Re: SPAM

2008-06-20 Thread Aspersieman
Michael Torrie wrote: Aspersieman wrote: SPAM Obviously. Please refrain from replying to the SPAM on this list. It just makes the problem worse. Thanks. -- http://mail.python.org/mailman/listinfo/python-list ErrrOk. I read somewhere that replying to potenti

Re: Regular expression

2008-06-20 Thread Duncan Booth
Sallu <[EMAIL PROTECTED]> wrote: > string = 'riché' ... > unicode(string)).encode('ASCII', 'ignore') ... > > Output : > > sys:1: DeprecationWarning: Non-ASCII character '\xc3' in file regu.py > on line 4, but no encoding declared; see > http://www.python.org/peps/pep-0263.html for details > riché

poplib - retr() getting stuck

2008-06-20 Thread Roopesh
Hi, I am using poplib's retr() to fetch mails from my gmail account. It works fine, in some cases it gets stuck inside the retr() method and does not come out. >From the logs I could find that when retr() is called, it stops executing further statements, nor does it throw an exceptions but simply

  1   2   >