Re: use strings to call functions

2010-02-08 Thread Paul Rudin
Steven D'Aprano writes: > On Mon, 08 Feb 2010 14:43:46 -0800, Aahz wrote: > WARNING: eval() is almost always the wrong answer to any question >>> >>>warning : it works ! >> >> Works for what? > > Code injection security bugs, of course. > > http://en.wikipedia.org/wiki/Code_injection > > It

Re: Python Logic Map/Logic Flow Chart. (Example Provided)

2010-02-08 Thread Gary Herron
spike wrote: On Feb 8, 1:35 pm, Gary Herron wrote: spike wrote: Has anyone been able to come across a Python logic map or Python logic flow chart? An example can be seen on the right under History: http://en.wikipedia.org/wiki/Usenet#History This would be very helpful fo

Re: C/C++ Import

2010-02-08 Thread Austin Bingham
Just to elaborate on Terry's point a bit, sys.path is influenced (in part) by the PYTHONPATH environment variable. If you find that the directory containing 'python' is not in sys.path (which you can check with 'import sys; print sys.path'), add that directory to PYTHONPATH and try again. This may

event handling in pyuthon

2010-02-08 Thread Bujji
hi all, any event handling mechanisms in python ? i want event handler examples in python Thanks Bujji -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-08 Thread Alf P. Steinbach
* Steven D'Aprano: On Tue, 09 Feb 2010 05:01:16 +0100, Alf P. Steinbach wrote: * Stephen Hansen -> Alf P. Steinbach: [snip] To say, "pass by value" implies things to people. It describes a sort of world where I'm a function about to do some work, and on my desk I have a series of boxes with na

Re: Python 3: Plist as OrderedDict

2010-02-08 Thread Raymond Hettinger
On Feb 8, 8:02 pm, Gnarlodious wrote: > I am trying to read a *.plist into Python 3's OrderedDict but can't > figure it out. Saying something like this: ... > I "upgraded" to Py3 to have OrderedDict, so please don't say it is > impossible... You may be able to monkey patch an OrderedDict into the

Re: ANN: obfuscate

2010-02-08 Thread Gregory Ewing
Tim Chase wrote: I prefer the strength of Triple ROT-13 for my obfuscation needs, but I don't see it listed here. That's old hat -- with the advent of 3GHz cpus and GPGPU, all the experts are recommending quadruple ROT-128 nowadays. -- Greg -- http://mail.python.org/mailman/listinfo/python-li

Re: Python Logic Map/Logic Flow Chart. (Example Provided)

2010-02-08 Thread spike
On Feb 8, 1:35 pm, Gary Herron wrote: > spike wrote: > > Has anyone been able to come across a Python logic map or Python logic > > flow chart? > > > An example can be seen on the right under History: > >http://en.wikipedia.org/wiki/Usenet#History > > > This would be very helpful for all users. >

Re: Python 3: Plist as OrderedDict

2010-02-08 Thread Ned Deily
In article , Terry Reedy wrote: > On 2/8/2010 11:02 PM, Gnarlodious wrote: > > I am trying to read a *.plist into Python 3's OrderedDict but can't > > figure it out. Saying something like this: > > from plistlib import readPlist > As a general note, include a link or something when discussing a

Re: Simple question about Queue.Queue and threads

2010-02-08 Thread Frank Millman
On Feb 8, 4:51 pm, Steven wrote: Queue objects have support for this signaling baked in with q.task_done and q.join. After the server process has put all tasks into the queue, it can join the queue itself, not the worker threads. q.join() This will block until all tasks have been gotten AND

Re: equivalent of Ruby's Pathname?

2010-02-08 Thread Gregory Ewing
Carl Banks wrote: I don't remember if the idea of modifying open to accept path objects came up. It wouldn't just be open() that people would want modified -- it would be every other function that takes a pathname as well. I seem to recall another point of contention was whether path objects s

Re: Modifying Class Object

2010-02-08 Thread Alf P. Steinbach
* Stephen Hansen: On Mon, Feb 8, 2010 at 8:01 PM, Alf P. Steinbach > wrote: * Stephen Hansen -> Alf P. Steinbach: [snip] To say, "pass by value" implies things to people. It describes a sort of world where I'm a function about to do some work

Re: use strings to call functions

2010-02-08 Thread Stephen Hansen
On Mon, Feb 8, 2010 at 10:00 PM, OdarR wrote: > On 9 fév, 02:50, Jean-Michel Pichavant wrote: > > Aahz wrote: > > > In article < > 0efe23a6-b16d-4f92-8bc0-12d056bf5...@z26g2000yqm.googlegroups.com>, > > > OdarR wrote: > > > > >> and with eval(), did you try ? > > > > > WARNING: eval() is almos

Re: use strings to call functions

2010-02-08 Thread OdarR
On 9 fév, 02:50, Jean-Michel Pichavant wrote: > Aahz wrote: > > In article > > <0efe23a6-b16d-4f92-8bc0-12d056bf5...@z26g2000yqm.googlegroups.com>, > > OdarR   wrote: > > >> and with eval(), did you try ? > > > WARNING: eval() is almost always the wrong answer to any question > > Some say that ev

Re: ctypes Structure serialization

2010-02-08 Thread Lawrence D'Oliveiro
In message <615b1271-a9b0-4558-8e45- e4370698d...@a16g2000pre.googlegroups.com>, rych wrote: > I'm not quite familiar with python serialization but the picle module, > at least, doesn't seem to be able to serialize a ctypes Structure with > array-fields. Remember that a ctypes structure is suppos

Re: Modifying Class Object

2010-02-08 Thread Steven D'Aprano
On Tue, 09 Feb 2010 05:01:16 +0100, Alf P. Steinbach wrote: > * Stephen Hansen -> Alf P. Steinbach: >> >> [snip] >> To say, "pass by value" implies things to people. It describes a sort >> of world where I'm a function about to do some work, and on my desk I >> have a series of boxes with names on

Re: equivalent of Ruby's Pathname?

2010-02-08 Thread Phlip
Carl Banks wrote: > I don't know if it was the reason it was rejected, but a seriously > divisive question is whether the path should be a subset of string. OMG that's nothing but the OO "circle vs ellipse" non-question. Glad to see the Committee derailed a perfectly good library over such sophis

Re: Modifying Class Object

2010-02-08 Thread Alf P. Steinbach
* Terry Reedy: On 2/8/2010 2:10 PM, Alf P. Steinbach wrote: I apologize for assuming that "pointer" is a known word to [c.l.p.] denizens. It is irrelevant. Python calls Python functions by associating argument objects (or objects derived therefrom) with paramenter names, very much like ass

Re: Python 3: Plist as OrderedDict

2010-02-08 Thread Terry Reedy
On 2/8/2010 11:02 PM, Gnarlodious wrote: I am trying to read a *.plist into Python 3's OrderedDict but can't figure it out. Saying something like this: from plistlib import readPlist As a general note, include a link or something when discussing a relatively obscure module that seems not to e

Re: xml.sax parsing elements with the same name

2010-02-08 Thread dontcare
If you are using jython, then you might also want to consider VTD-XML, which is a lot easier to use and faster than SAX, native XPath support may be useful too http;//vtd-xml.sf.net On Jan 12, 12:13 am, Stefan Behnel wrote: > amadain, 11.01.2010 20:13: > > > > > > > I have an event log with 100s

Re: Modifying Class Object

2010-02-08 Thread Stephen Hansen
On Mon, Feb 8, 2010 at 8:01 PM, Alf P. Steinbach wrote: > * Stephen Hansen -> Alf P. Steinbach: > >> >> [snip] >> >> To say, "pass by value" implies things to people. It describes a sort of >> world where I'm a function about to do some work, and on my desk I have a >> series of boxes with names

Re: Modifying Class Object

2010-02-08 Thread Terry Reedy
On 2/8/2010 2:10 PM, Alf P. Steinbach wrote: I apologize for assuming that "pointer" is a known word to [c.l.p.] denizens. It is irrelevant. Python calls Python functions by associating argument objects (or objects derived therefrom) with paramenter names, very much like assigment statement

Re: Python 3: Plist as OrderedDict

2010-02-08 Thread Benjamin Kaplan
On Mon, Feb 8, 2010 at 11:02 PM, Gnarlodious wrote: > I am trying to read a *.plist into Python 3's OrderedDict but can't > figure it out. Saying something like this: > > from plistlib import readPlist > dict=readPlist('/path/file.plist') > --> arbitrarily ordered dictionary compared to the XML fi

Re: Python 3: Plist as OrderedDict

2010-02-08 Thread Ben Finney
Gnarlodious writes: > from plistlib import readPlist > dict=readPlist('/path/file.plist') > --> arbitrarily ordered dictionary compared to the XML file Right. The items in a dict are unordered, and when serialised to a list they will appear in an arbitrary, unpredictable order. >>> foo = di

Python 3: Plist as OrderedDict

2010-02-08 Thread Gnarlodious
I am trying to read a *.plist into Python 3's OrderedDict but can't figure it out. Saying something like this: from plistlib import readPlist dict=readPlist('/path/file.plist') --> arbitrarily ordered dictionary compared to the XML file from collections import OrderedDict OrderedDict(readPlist('/

Re: Modifying Class Object

2010-02-08 Thread Alf P. Steinbach
* Stephen Hansen -> Alf P. Steinbach: [snip] To say, "pass by value" implies things to people. It describes a sort of world where I'm a function about to do some work, and on my desk I have a series of boxes with names on it. It describes an environment where someone comes over and drops some

Tangling with mathplotlib(MPL) on XP and Win7 -- show() stopper

2010-02-08 Thread W. eWatson
I'm doing most of this on a win7 machine. When I installed MPL, I had two small dialogs appear that said something was missing, but I pressed on. MPL seemed to generally work except for the show() problem. When it was to be executed to show the output of plot(x,y), it did just that; however, th

Re: Socket Error: Permission Denied

2010-02-08 Thread W. eWatson
On 2/8/2010 7:24 PM, W. eWatson wrote: I'm using IDLE with winxp. It seems every day I get into the Subject above. Usually, after 5-8 minutes I get past it. A msg appearing at the same time say, "IDLE's subprocess didn't make connect. ... possible firewall problem." A resource for this is

Socket Error: Permission Denied

2010-02-08 Thread W. eWatson
I'm using IDLE with winxp. It seems every day I get into the Subject above. Usually, after 5-8 minutes I get past it. A msg appearing at the same time say, "IDLE's subprocess didn't make connect. ... possible firewall problem." A resource for this is . There a

Re: Modifying Class Object

2010-02-08 Thread Stephen Hansen
On Mon, Feb 8, 2010 at 7:07 PM, MRAB wrote: > This is getting out of hand. >> >> First, someone thought I was you. >> >> Now you think I'm D'Aprano. >> >> I'm just gonna go by Bob for now on. >> :) >> >> --B >> >> Bruce would be less confusing. :-) I've heard that, and can't fathom the claim.

Re: Modifying Class Object

2010-02-08 Thread MRAB
Stephen Hansen wrote: On Mon, Feb 8, 2010 at 6:42 PM, Steve Holden > wrote: Stephen Hansen wrote: [...] > P.S. I couldn't resist. :( > And here I was, sitting on my hands ... but someone was wrong on the Internet, so D'Aprano had to put them

Re: Python Logic Map/Logic Flow Chart. (Example Provided)

2010-02-08 Thread Carl Banks
On Feb 8, 1:35 pm, Gary Herron wrote: > spike wrote: > > Has anyone been able to come across a Python logic map or Python logic > > flow chart? > > > An example can be seen on the right under History: > >http://en.wikipedia.org/wiki/Usenet#History > > > This would be very helpful for all users. >

Re: Python Logic Map/Logic Flow Chart. (Example Provided)

2010-02-08 Thread Carl Banks
On Feb 8, 12:20 pm, spike wrote: > Has anyone been able to come across a Python logic map or Python logic > flow chart? > > An example can be seen on the right under > History:http://en.wikipedia.org/wiki/Usenet#History > > This would be very helpful for all users. Begin | | V Start Edito

Re: Ternary plus

2010-02-08 Thread Carl Banks
On Feb 8, 12:59 pm, Martin Drautzburg wrote: > Just for the hell of it ... > > I can easily define __plus__() with three parameters. If the last one is > optional the + operation works as expected. Is there a way to pass the > third argument to "+" If, for some reason, you wanted to define a type

Re: Modifying Class Object

2010-02-08 Thread Stephen Hansen
On Mon, Feb 8, 2010 at 6:42 PM, Steve Holden wrote: > Stephen Hansen wrote: > [...] > > P.S. I couldn't resist. :( > > > > And here I was, sitting on my hands ... but someone was wrong on the > Internet, so D'Aprano had to put them right. Your fatal weakness. > > Of course this won't make the sli

Re: timer for a function

2010-02-08 Thread Stephen Hansen
On Fri, Feb 5, 2010 at 9:23 AM, mk wrote: > On paramiko mailing list I got the suggestion to build a timer and then > quit this by myself: > > The timeout option in connect() is for the socket, not for the entire >> operation. You are connected, so that timeout is no longer relevant. >> You woul

Re: Modifying Class Object

2010-02-08 Thread Steve Holden
Stephen Hansen wrote: [...] > P.S. I couldn't resist. :( > And here I was, sitting on my hands ... but someone was wrong on the Internet, so D'Aprano had to put them right. Your fatal weakness. Of course this won't make the slightest difference. "'When I use a word,' said Humpty ..." regards S

Re: ANN: obfuscate

2010-02-08 Thread Chris Colbert
I always though a double rot13 followed by a rot26 was the best? On Mon, Feb 8, 2010 at 9:19 PM, Tim Chase wrote: > Steven D'Aprano wrote: > >> obfuscate is a pure-Python module providing classical encryption >> algorithms suitable for obfuscating and unobfuscating text. >> >> obfuscate includes

Re: ANN: obfuscate

2010-02-08 Thread Tim Chase
Steven D'Aprano wrote: obfuscate is a pure-Python module providing classical encryption algorithms suitable for obfuscating and unobfuscating text. obfuscate includes the following ciphers: - Caesar, rot13, rot5, rot18, rot47 - atbash - Playfair, Playfair6 and Playfair16 - Railfence (encryp

Re: Terminating threaded programs

2010-02-08 Thread Stephen Hansen
On Fri, Feb 5, 2010 at 7:25 AM, mk wrote: > Hello everyone, > > I have a problem with a threaded program: it frequently hangs on sys.exit. > I use threads all the time (well, for certain types of workloads) and have never seen this. Are your threads daemon threads? The only time I've seen sys.e

Re: use strings to call functions

2010-02-08 Thread Stephen Hansen
On Mon, Feb 8, 2010 at 5:51 PM, Steven D'Aprano < ste...@remove.this.cybersource.com.au> wrote: > On Mon, 08 Feb 2010 14:43:46 -0800, Aahz wrote: > > >>> WARNING: eval() is almost always the wrong answer to any question > >> > >>warning : it works ! > > > > Works for what? > > Code injection secur

Re: Modifying Class Object

2010-02-08 Thread MRAB
Alf P. Steinbach wrote: * Steve Holden: Alf P. Steinbach wrote: * Steve Holden: [...] Alf: This topic was discussed at great, nay interminable, length about a year ago. I'd appreciate it if you would search the archives and read what was said then rather than hashing the whole topic over a

Re: Modifying Class Object

2010-02-08 Thread MRAB
Steven D'Aprano wrote: On Mon, 08 Feb 2010 02:51:05 +0100, Alf P. Steinbach wrote: Python passes pointers by value, just as e.g. Java does. How do I get a pointer in pure Python code (no ctypes)? I tried both Pascal and C syntax (^x and *x), but both give syntax errors. In Pascal it's x^.

Re: Modifying Class Object

2010-02-08 Thread Stephen Hansen
On Mon, Feb 8, 2010 at 4:44 PM, Alf P. Steinbach wrote: > No, one only needs an understanding of "pointer". > > "Pointer" is a mostly language independent concept. > > The reference to the Java language spec, where that term is used for this, > was just an unsuccessful attempt to keep out word-pl

Re: use strings to call functions

2010-02-08 Thread Steven D'Aprano
On Mon, 08 Feb 2010 14:43:46 -0800, Aahz wrote: >>> WARNING: eval() is almost always the wrong answer to any question >> >>warning : it works ! > > Works for what? Code injection security bugs, of course. http://en.wikipedia.org/wiki/Code_injection It is surprisingly difficult to sanitize stri

Re: use strings to call functions

2010-02-08 Thread Jean-Michel Pichavant
Aahz wrote: In article <0efe23a6-b16d-4f92-8bc0-12d056bf5...@z26g2000yqm.googlegroups.com>, OdarR wrote: and with eval(), did you try ? WARNING: eval() is almost always the wrong answer to any question Some say that eval is evil ! JM -- http://mail.python.org/mailman/listinfo/py

Re: Ternary plus

2010-02-08 Thread Steven D'Aprano
On Mon, 08 Feb 2010 21:59:18 +0100, Martin Drautzburg wrote: > Just for the hell of it ... > > I can easily define __plus__() with three parameters. If the last one is > optional the + operation works as expected. Is there a way to pass the > third argument to "+" How do you give three operands

Re: timer for a function

2010-02-08 Thread Steven D'Aprano
On Fri, 05 Feb 2010 18:23:09 +0100, mk wrote: [...] > On paramiko mailing list I got the suggestion to build a timer and then > quit this by myself: > >> The timeout option in connect() is for the socket, not for the entire >> operation. You are connected, so that timeout is no longer relevant. >

Re: Your beloved python features

2010-02-08 Thread Steven D'Aprano
On Mon, 08 Feb 2010 18:07:56 +0100, mk wrote: >> Threads are hard, and many people don't use them at all. You might >> never get an answer, even without alienating people. Complaining after >> six DAYS might be acceptable, if you do it with a sense of humour, but >> after six minutes? > > Well, i

Re: Read PGM's with more than 256 range in PIL1.1.7

2010-02-08 Thread Chris Colbert
According the pil manual it handles PGM files with "'1', 'L', or 'RGB' data" which leads me to believe 16bit data is not supported. You CAN write your own decoder for that though: http://www.pythonware.com/library/pil/handbook/decoder.htm It would be trivial to write a decoder for the pgm format.

Re: Modifying Class Object

2010-02-08 Thread Alf P. Steinbach
* alex23: "Alf P. Steinbach" wrote: Hm. While most everything I've seen at effbot.org has been clear and to the point, that particular article reads like a ton of obfuscation. Must. Resist. Ad hominem. Python passes pointers by value, just as e.g. Java does. There, it needed just 10 words

Re: ANN: obfuscate

2010-02-08 Thread geremy condra
On Mon, Feb 8, 2010 at 6:46 PM, Steven D'Aprano wrote: > I am pleased to announce the first public release of obfuscate 0.2.2a. > > http://pypi.python.org/pypi/obfuscate/0.2.2a > > obfuscate is a pure-Python module providing classical encryption > algorithms suitable for obfuscating and unobfuscat

Re: equivalent of Ruby's Pathname?

2010-02-08 Thread Carl Banks
On Feb 4, 7:10 pm, Sean DiZazzo wrote: > On Feb 3, 6:08 pm, alex23 wrote: > > > > > On Feb 4, 8:47 am, Phlip wrote: > > > > Yes, calling os.path.walk() and os.path.join() all the time on raw > > > strings is fun, but I seem to recall from my Ruby days a class called > > > Pathname, which present

Re: ANN: obfuscate

2010-02-08 Thread Christian Heimes
Steven D'Aprano schrieb: > I am pleased to announce the first public release of obfuscate 0.2.2a. > > http://pypi.python.org/pypi/obfuscate/0.2.2a > > obfuscate is a pure-Python module providing classical encryption > algorithms suitable for obfuscating and unobfuscating text. > > obfuscate inc

ANN: obfuscate

2010-02-08 Thread Steven D'Aprano
I am pleased to announce the first public release of obfuscate 0.2.2a. http://pypi.python.org/pypi/obfuscate/0.2.2a obfuscate is a pure-Python module providing classical encryption algorithms suitable for obfuscating and unobfuscating text. obfuscate includes the following ciphers: - Caesar, r

Re: Building a multiline string

2010-02-08 Thread Aahz
In article , lallous wrote: > >x = ( >"line1" # can use comments >"line2" >"line3" >) You should indent the second and following lines (I changed the name to "xyz" to make clear that the following lines use a regular Python indent rather than lining up under the open paren): xyz = ( "line1"

Re: Your beloved python features

2010-02-08 Thread Aahz
In article <28c6967f-7637-4823-aee9-15487e1ce...@o28g2000yqh.googlegroups.com>, Julian wrote: > >I want to design a poster for an open source conference, the local >usergroup will have a table there, and in the past years there were >some people that came to the python-table just to ask "why shou

Re: equivalent of Ruby's Pathname?

2010-02-08 Thread Phlip
On Feb 8, 2:36 pm, a...@pythoncraft.com (Aahz) wrote: > >> There was also a PEP with another possible implementation: > >>http://www.python.org/dev/peps/pep-0355/ > > >Why did Path() get rejected?  Is it the idea itself, or just the > >approach that was used?  What are the complaints? > > You shou

Re: Your beloved python features

2010-02-08 Thread MRAB
geremy condra wrote: On Mon, Feb 8, 2010 at 12:07 PM, mk wrote: Steven D'Aprano wrote: On Fri, 05 Feb 2010 18:29:07 +0100, mk wrote: Ethan Furman wrote: http://www1.american.edu/academic.depts/cas/econ/faculty/isaac/ choose_python.pdf Choose to get your difficult questions about threads

Re: use strings to call functions

2010-02-08 Thread Aahz
In article <5790c33c-13d0-4596-91b0-b3c9aeebf...@f8g2000yqn.googlegroups.com>, OdarR wrote: >On 8 f=E9v, 22:28, a...@pythoncraft.com (Aahz) wrote: >> In article <0efe23a6-b16d-4f92-8bc0-12d056bf5...@z26g2000yqm.googlegroups= >.com>, >> OdarR =A0 wrote: >>> >>>and with eval(), did you try ? >> >>

Re: equivalent of Ruby's Pathname?

2010-02-08 Thread Aahz
In article , Sean DiZazzo wrote: >On Feb 3, 6:08=A0pm, alex23 wrote: >> >> There was also a PEP with another possible implementation: >> http://www.python.org/dev/peps/pep-0355/ > >Why did Path() get rejected? Is it the idea itself, or just the >approach that was used? What are the complaints

Re: Stephen -- Bruce?

2010-02-08 Thread Mensanator
On Feb 8, 3:02 am, Stefan Behnel wrote: > Mensanator, 05.02.2010 00:36: > > > On Feb 4, 5:13 pm, "Alf P. Steinbach" wrote: > >> What's this about all the Stephen'ses here? > > >> Shouldn't it be Bruce? > > > Of course. We just call everyone Stephen to avoid confusion. > > Some people even manage t

Read PGM's with more than 256 range in PIL1.1.7

2010-02-08 Thread Davo
I have a PGM format image file with 4096 range. When I reads it with PIL, I get an image with 8-bit values and alternate columns are zero. Does PIL support reading and writing PGM's with more than 8-bits? Davo -- http://mail.python.org/mailman/listinfo/python-list

Re: use strings to call functions

2010-02-08 Thread OdarR
On 8 fév, 22:28, a...@pythoncraft.com (Aahz) wrote: > In article > <0efe23a6-b16d-4f92-8bc0-12d056bf5...@z26g2000yqm.googlegroups.com>, > > OdarR   wrote: > > >and with eval(), did you try ? > > WARNING: eval() is almost always the wrong answer to any question warning : it works ! another questio

Re: Import question

2010-02-08 Thread Andrew Degtiariov
Those are called namespace packages. Zope and Plone (ab)use them > extensively. The intended usage is to break up a big, monolithic package > [0] in parts that can be distributed independently. To implement a > namespace package, you need an empty __init__.py file with only these > lines [1]: > >

Re: Python Logic Map/Logic Flow Chart. (Example Provided)

2010-02-08 Thread Gary Herron
spike wrote: Has anyone been able to come across a Python logic map or Python logic flow chart? An example can be seen on the right under History: http://en.wikipedia.org/wiki/Usenet#History This would be very helpful for all users. Huh??? What aspect of Python were you thinking of mappin

Re: use strings to call functions

2010-02-08 Thread Aahz
In article <0efe23a6-b16d-4f92-8bc0-12d056bf5...@z26g2000yqm.googlegroups.com>, OdarR wrote: > >and with eval(), did you try ? WARNING: eval() is almost always the wrong answer to any question -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ import antigravity -

Re: Awful book warning: How to think like a (Python) programmer - non-working examples

2010-02-08 Thread Andrej Mitrovic
On Feb 8, 10:14 pm, David Malcolm wrote: > On Mon, 2010-02-08 at 12:53 -0800, Andrej Mitrovic wrote: > > The book covers Python 2.x syntax. > > > You might have downloaded Python 3.1, which has different syntax then > > Python 2.x. From what I can tell, the first example on page 7 is ">>> > > prin

Re: Ternary plus

2010-02-08 Thread Robert Kern
On 2010-02-08 14:59 PM, Martin Drautzburg wrote: Just for the hell of it ... I can easily define __plus__() with three parameters. If the last one is optional the + operation works as expected. Is there a way to pass the third argument to "+" No. -- Robert Kern "I have come to believe that t

Ternary plus

2010-02-08 Thread Martin Drautzburg
Just for the hell of it ... I can easily define __plus__() with three parameters. If the last one is optional the + operation works as expected. Is there a way to pass the third argument to "+" -- http://mail.python.org/mailman/listinfo/python-list

Re: Simulating logging.exception with another traceback

2010-02-08 Thread Vinay Sajip
On Feb 7, 11:22 am, Joan Miller wrote: > I would want to get the output from `logging.exception` but with > traceback from the caller function (I've already all that > information). > > This would be the error withlogging.exception: > > ERROR: >   PipeError('/bin/ls -l |  ', '

Re: Awful book warning: How to think like a (Python) programmer - non-working examples

2010-02-08 Thread David Malcolm
On Mon, 2010-02-08 at 12:53 -0800, Andrej Mitrovic wrote: > The book covers Python 2.x syntax. > > You might have downloaded Python 3.1, which has different syntax then > Python 2.x. From what I can tell, the first example on page 7 is ">>> > print 1 + 1". > > Try issuing this command: > print(1

glibc detected double free or corruption

2010-02-08 Thread Aryeh Leib Taurog
I'm encountering the following error on my fastcgi web server and would greatly appreciate ANY pointers for debugging/fixing this problem. *** glibc detected *** /usr/bin/python2.5: double free or corruption (fasttop): 0x08b47d60 *** If I don't set MALLOC_CHECK_ then the server just hangs and the

Re: Awful book warning: How to think like a (Python) programmer - non-working examples

2010-02-08 Thread Andrej Mitrovic
The book covers Python 2.x syntax. You might have downloaded Python 3.1, which has different syntax then Python 2.x. From what I can tell, the first example on page 7 is ">>> print 1 + 1". Try issuing this command: print(1 + 1) If everything goes well, and you get '2' as the answer, then you're

Re: Awful book warning: How to think like a (Python) programmer - non-working examples

2010-02-08 Thread Robert Kern
On 2010-02-08 14:36 PM, Dave Peterson wrote: Page 7: Very first example doesn't compile: syntax error Pate 11: 2nd example: syntax error Page 12, printing digits: syntax error Page 13, printing a number: syntax error page 14, statements: syntax error This book was written for the 2.x versions o

Re: Awful book warning: How to think like a (Python) programmer - non-working examples

2010-02-08 Thread Benjamin Kaplan
On Mon, Feb 8, 2010 at 3:36 PM, Dave Peterson wrote: > Page 7: Very first example doesn't compile: syntax error > Pate 11: 2nd example: syntax error > Page 12, printing digits: syntax error > Page 13, printing a number: syntax error > page 14, statements: syntax error > Let me guess, you're using

Awful book warning: How to think like a (Python) programmer - non-working examples

2010-02-08 Thread Dave Peterson
Page 7: Very first example doesn't compile: syntax error Pate 11: 2nd example: syntax error Page 12, printing digits: syntax error Page 13, printing a number: syntax error page 14, statements: syntax error -- http://mail.python.org/mailman/listinfo/python-list

Python Logic Map/Logic Flow Chart. (Example Provided)

2010-02-08 Thread spike
Has anyone been able to come across a Python logic map or Python logic flow chart? An example can be seen on the right under History: http://en.wikipedia.org/wiki/Usenet#History This would be very helpful for all users. -- http://mail.python.org/mailman/listinfo/python-list

Does anyone have a Python Logic Map/Flow Chart? (Example Provided)

2010-02-08 Thread spike
Has anyone been able to come across a Python logic map or flow chart? An example can be seen here on the right: http://en.wikipedia.org/wiki/Usenet This would be very helpful for users. -- http://mail.python.org/mailman/listinfo/python-list

Re: Your beloved python features

2010-02-08 Thread geremy condra
On Mon, Feb 8, 2010 at 12:07 PM, mk wrote: > Steven D'Aprano wrote: >> >> On Fri, 05 Feb 2010 18:29:07 +0100, mk wrote: >> >>> Ethan Furman wrote: >>> http://www1.american.edu/academic.depts/cas/econ/faculty/isaac/ >> >> choose_python.pdf >>> Choose to get your difficult questions about

setuptools/distutil and pywin32

2010-02-08 Thread Giampaolo Rodola'
Hi, I have a program which requires pywin32 as a dependancy and I'd like to make setuptools automatically retrieve it from internet and install it. My setup.py script looks like this: from setuptools import setup setup( ... ... install_requires = ['pywin32']

Re: use strings to call functions

2010-02-08 Thread Gary Herron
OdarR wrote: On 8 fév, 11:57, Klaus Neuner wrote: Hello, I am writing a program that analyzes files of different formats. I would like to use a function for each format. Obviously, functions can be mapped to file formats. E.g. like this: if file.endswith('xyz'): xyz(file) elif file.end

Re: use strings to call functions

2010-02-08 Thread OdarR
On 8 fév, 11:57, Klaus Neuner wrote: > Hello, > > I am writing a program that analyzes files of different formats. I > would like to use a function for each format. Obviously, functions can > be mapped to file formats. E.g. like this: > > if file.endswith('xyz'): >     xyz(file) > elif file.endswi

Re: Import question

2010-02-08 Thread Gabriel Genellina
En Mon, 08 Feb 2010 06:37:53 -0300, Andrew Degtiariov escribió: 2010/2/6 Gabriel Genellina En Fri, 05 Feb 2010 13:21:47 -0300, Andrew Degtiariov escribió: Code of our project has split into several packages and we deploy the project using buildout. All worked fine until I need to dynamical

Re: Modifying Class Object

2010-02-08 Thread Alf P. Steinbach
* Diez B. Roggisch: Am 08.02.10 02:51, schrieb Alf P. Steinbach: * Chris Rebert: On Sun, Feb 7, 2010 at 5:05 PM, T wrote: Ok, just looking for a sanity check here, or maybe something I'm missing. I have a class Test, for example: class Test: def __init__(self, param1, param2, param3): self.p

Re: Modifying Class Object

2010-02-08 Thread Diez B. Roggisch
Am 08.02.10 02:51, schrieb Alf P. Steinbach: * Chris Rebert: On Sun, Feb 7, 2010 at 5:05 PM, T wrote: Ok, just looking for a sanity check here, or maybe something I'm missing. I have a class Test, for example: class Test: def __init__(self, param1, param2, param3): self.param1 = param1 self.p

Re: intolerant HTML parser

2010-02-08 Thread Phlip
and the tweak is: parser = etree.HTMLParser(recover=False) return etree.HTML(xml, parser) That reduces tolerance. The entire assert_xml() is (apologies for wrapping lines!): def _xml_to_tree(self, xml): from lxml import etree self._xml = xml

Re: Modifying Class Object

2010-02-08 Thread Duncan Booth
T wrote: > Duncan - Thanks for your help. So each of the shelve entries I'm > modifying look something like this: myshelve[key] > TestClassObject(param1, param2, param3, param4, param5, etc.). In > this case, with quite a few parameters, would you suggest setting > writeback=True and just mod

Re: intolerant HTML parser

2010-02-08 Thread Phlip
Stefan Behnel wrote: > I don't read it that way. There's a huge difference between > > - generating HTML manually and validating (some of) it in a unit test > > and > > - generating HTML using a tool that guarantees correct HTML output > > the advantage of the second approach being that others hav

Re: Modifying Class Object

2010-02-08 Thread T
On Feb 8, 4:00 am, Duncan Booth wrote: > T wrote: > > Oops, this one was my fault - the object I was having the issues with > > was actually a shelve file, not a dictionary..so just re-assigning the > > variable isn't working, but re-writing the object to the shelve file > > does.  So in this cas

Re: Your beloved python features

2010-02-08 Thread mk
Steven D'Aprano wrote: On Fri, 05 Feb 2010 18:29:07 +0100, mk wrote: Ethan Furman wrote: http://www1.american.edu/academic.depts/cas/econ/faculty/isaac/ choose_python.pdf Choose to get your difficult questions about threads in Python ignored. Oh well.. With an attitude like that, you're

Re: Overcoming python performance penalty for multicore CPU

2010-02-08 Thread John Krukoff
On Mon, 2010-02-08 at 01:10 -0800, Paul Rubin wrote: > Stefan Behnel writes: > > Well, if multi-core performance is so important here, then there's a pretty > > simple thing the OP can do: switch to lxml. > > > > http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ > > Well, lxml

Re: C/C++ Import

2010-02-08 Thread Terry Reedy
On 2/7/2010 10:56 PM, 7H3LaughingMan wrote: To make the background information short, I am trying to take a program that uses Python for scripting and recompile it for Linux since it originally was built to run on Win32. The program itself was designed to be able to be compiled on Linux and someo

Re: Executing Commands From Windows Service

2010-02-08 Thread T
On Feb 8, 1:28 am, Sean DiZazzo wrote: > On Feb 7, 4:57 pm, T wrote: > > > Thanks for the suggestions -  I think my next step is to try running > > it under an admin user account, as you guys both mentioned.  Alf - > > you're absolutely right, Microsoft has srvany.exe, which allows you to > > run

Re: threading+popen2 hang

2010-02-08 Thread Aahz
In article <2542cf60-a193-4087-a1fe-1d60ee13c...@v25g2000yqk.googlegroups.com>, lofic wrote: >On 7 f=E9v, 17:00, a...@pythoncraft.com (Aahz) wrote: >> In article <188bfb67-3334-4325-adfc-3fa4d28f0...@d27g2000yqn.googlegroups= >.com>, >> lofic =A0 wrote: >>> >>>Works fine on RHEL5/python 2.4.3 >>>

Re: Overcoming python performance penalty for multicore CPU

2010-02-08 Thread J Kenneth King
Paul Rubin writes: > Stefan Behnel writes: >> Well, if multi-core performance is so important here, then there's a pretty >> simple thing the OP can do: switch to lxml. >> >> http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ > > Well, lxml is uses libxml2, a fast XML parser w

Re: [PyOpenGL-Users] Mouse wheel events?

2010-02-08 Thread Gary Herron
Craig Berry wrote: On Sun, Feb 7, 2010 at 22:26, Gary Herron wrote: Didn't I answer this already? If you did, for whatever reason I didn't see it; I just rechecked my inbox to be sure. Thanks for doing so again! I assume, given the list we're on, that Freeglut can be used with Pytho

Re: Create a backslash-escaped version of a string?

2010-02-08 Thread boblatest
On Feb 8, 12:28 pm, Chris Rebert wrote: > print a.encode("string-escape") How could I miss that? I was on that doc page already. Should have typed "/escape" in the browser ;-) Thanks, robert -- http://mail.python.org/mailman/listinfo/python-list

Re: method names nounVerb or verbNoun

2010-02-08 Thread Wanderer
On Feb 5, 5:21 pm, Wanderer wrote: > On Feb 5, 4:53 pm, Chris Rebert wrote: > > > > > On Fri, Feb 5, 2010 at 1:49 PM, Wanderer wrote: > > > On Feb 5, 3:26 pm, Chris Rebert wrote: > > >> On Fri, Feb 5, 2010 at 11:53 AM, Wanderer > > >> wrote: > > >> > Which is the more accepted way to compose

Re: Modifying Class Object

2010-02-08 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Steve Holden: [...] Alf: This topic was discussed at great, nay interminable, length about a year ago. I'd appreciate it if you would search the archives and read what was said then rather than hashing the whole topic over again to nobody's real advan

  1   2   >