Re: How to pop the interpreter's stack?

2010-12-16 Thread Terry Reedy
On 12/16/2010 7:33 PM, Steven D'Aprano wrote: Python's exception system has to handle two different situations: buggy code, and bad data. It's not even clear whether there is a general distinction to be made between the two, but even if there's not a general distinction, there's certainly a dist

Re: How to pop the interpreter's stack?

2010-12-16 Thread John Nagle
On 12/14/2010 6:31 PM, Ethan Furman wrote: kj wrote: The one thing I don't like about this strategy is that the tracebacks of exceptions raised during the execution of __pre_spam include one unwanted stack level (namely, the one corresponding to __pre_spam itself). __pre_spam should be complete

Re: How to pop the interpreter's stack?

2010-12-16 Thread Carl Banks
On Dec 15, 2:16 am, Steven D'Aprano wrote: > On Tue, 14 Dec 2010 21:14:35 +, kj wrote: > > Consider this code: > > > def spam(*args, **kwargs): > >     args, kwargs = __pre_spam(*args, **kwargs) > > >     # args & kwargs are OK: proceed > >     # ... > > > def __pre_spam(*args, **kwargs): > >

Re: If/then style question

2010-12-16 Thread Steve Holden
On 12/16/2010 11:32 PM, Carl Banks wrote: > On Dec 16, 2:56 pm, Ryan Kelly wrote: >> On Thu, 2010-12-16 at 21:49 +, John Gordon wrote: >>> (This is mostly a style question, and perhaps one that has already been >>> discussed elsewhere. If so, a pointer to that discussion will be >>> appreciat

Re: Newbie question about importing modules.

2010-12-16 Thread Jony Zhu
Hi, cronoklee maybe you should check every module directory you want to import to see if there is a __init__.py in it? missing a __init__.py file would cause error when you try to import the directory as a module. 在 Fri, 17 Dec 2010 11:42:48 +0800,cronoklee 写道: Hi I'm starting my first p

Re: If/then style question

2010-12-16 Thread Carl Banks
On Dec 16, 2:56 pm, Ryan Kelly wrote: > On Thu, 2010-12-16 at 21:49 +, John Gordon wrote: > > (This is mostly a style question, and perhaps one that has already been > > discussed elsewhere.  If so, a pointer to that discussion will be > > appreciated!) > > > When I started learning Python, I

Newbie question about importing modules.

2010-12-16 Thread cronoklee
Hi I'm starting my first python project but I'm having trouble getting off the ground. I've read all I can find about relative and absolute import paths but it's just not making sense to me... There seems to be around ten different ways to import a script. I need my project to be portable so I can

Re: Read / Write OpenOffice SpreadSheet ?

2010-12-16 Thread joymanchen
"Torsten Mohr" 写入消息 news:ieed6o$iq...@news.lf.net... Hi, i search for a possibility to access OpenOffoce SpreadSheets from Python with a reasonably new version of Python. Can anybody point me to a package that can do this? Best regards, Torsten. --- news://freenews.netfront.net/ - comp

Re: Read / Write OpenOffice SpreadSheet ?

2010-12-16 Thread Tim Chase
On 12/16/2010 07:53 PM, Tim Harig wrote: On 2010-12-17, Torsten Mohr wrote: i search for a possibility to access OpenOffoce SpreadSheets from Python with a reasonably new version of Python. Can anybody point me to a package that can do this? There is no package needed to read or write the ne

Re: Read / Write OpenOffice SpreadSheet ?

2010-12-16 Thread Tim Harig
On 2010-12-17, Torsten Mohr wrote: > i search for a possibility to access OpenOffoce SpreadSheets from Python > with a reasonably new version of Python. > > Can anybody point me to a package that can do this? There is no package needed to read or write the new open document files. The files are

Re: If/then style question

2010-12-16 Thread Joel Koltner
"Steven D'Aprano" wrote in message news:4d0aa5e7$0$29997$c3e8da3$54964...@news.astraweb.com... It doesn't look like you were learning Python. It looks like you were learning C with Python syntax :( True, although in many cases one has to interface to legacy C code where it'd be rather more co

Re: Read / Write OpenOffice SpreadSheet ?

2010-12-16 Thread Emile van Sebille
On 12/16/2010 5:07 PM Torsten Mohr said... Hi, i search for a possibility to access OpenOffoce SpreadSheets from Python with a reasonably new version of Python. Can anybody point me to a package that can do this? If you're open to 'saving as xls' then xlrd/xlwt works well. Otherwise, when

Read / Write OpenOffice SpreadSheet ?

2010-12-16 Thread Torsten Mohr
Hi, i search for a possibility to access OpenOffoce SpreadSheets from Python with a reasonably new version of Python. Can anybody point me to a package that can do this? Best regards, Torsten. -- http://mail.python.org/mailman/listinfo/python-list

Re: while True or while 1

2010-12-16 Thread Steven D'Aprano
On Thu, 16 Dec 2010 23:34:21 +, BartC wrote: > In terms of a more realistic function (admittedly still a little > contrived, as the loop would be written differently), I tried this: > > def p2(n): > p=1 > while True: > if n<=p: return p > p<<=1 > return 0 > > for i in xrange(10

Re: string identity and comparison

2010-12-16 Thread alex23
On Dec 16, 9:55 pm, Jean-Michel Pichavant wrote: > I'd like to illutrate the fact that comparing strings using identity is, > most of the time, a bad idea. However I'm searching a short example of > code that yields 2 differents object for the same string content. > > Anyone has that kind of code

Re: How to pop the interpreter's stack?

2010-12-16 Thread Steven D'Aprano
On Thu, 16 Dec 2010 10:39:34 -0600, Robert Kern wrote: > On 12/16/10 10:23 AM, Steven D'Aprano wrote: >> On Thu, 16 Dec 2010 07:29:25 -0800, Ethan Furman wrote: >> >>> Tim Arnold wrote: "Ethan Furman" wrote in message news:mailman.4.1292379995.6505.python-l...@python.org... > kj wro

Re: If/then style question

2010-12-16 Thread alex23
John Gordon wrote: > But lately I've been preferring this style: > >   def myMethod(self, arg1, arg2): > >     if some_bad_condition: >       return bad1 > >     elif some_other_bad_condition: >       return bad2 > >     elif yet_another_bad_condition: >       return bad3 > >     do_some_useful_st

Re: while True or while 1

2010-12-16 Thread Ian
On Dec 16, 4:34 pm, "BartC" wrote: > def p2(n): >   p=1 >  whileTrue: >     if n<=p: return p >     p<<=1 >   return 0 > > for i in xrange(100): >   x=p2(i) > > p2() calculates the smallest power of 2 >= it's operand. def p2(n): return 1 << n.bit_length() -- http://mail.python.org/mailman/

Re: If/then style question

2010-12-16 Thread Steven D'Aprano
On Thu, 16 Dec 2010 21:49:07 +, John Gordon wrote: > (This is mostly a style question, and perhaps one that has already been > discussed elsewhere. If so, a pointer to that discussion will be > appreciated!) > > When I started learning Python, I wrote a lot of methods that looked > like this

Re: while True or while 1

2010-12-16 Thread BartC
"Steve Holden" wrote in message news:mailman.54.1292502247.6505.python-l...@python.org... On 12/16/2010 5:44 AM, BartC wrote: One these is 30% faster than the other. That's an appreciable difference, which you can't really just dismiss. shol...@lifeboy ~ $ python -m timeit -- "i = 1" "whi

Re: If/then style question

2010-12-16 Thread Ian Kelly
On Thu, Dec 16, 2010 at 3:41 PM, Stefan Sonnenberg-Carstens wrote: > return [x for x,y in > ((bad1,some_bad_condition),(bad2,some_other_bad_condition),(bad3,yet_another_bad_condition),(good1,do_some_useful_stuff() > or True)) if x][0] This doesn't work. do_some_usefull_stuff() gets called during

Re: If/then style question

2010-12-16 Thread Ryan Kelly
On Thu, 2010-12-16 at 21:49 +, John Gordon wrote: > (This is mostly a style question, and perhaps one that has already been > discussed elsewhere. If so, a pointer to that discussion will be > appreciated!) > > When I started learning Python, I wrote a lot of methods that looked like > this:

Re: If/then style question

2010-12-16 Thread Stefan Sonnenberg-Carstens
Am 16.12.2010 22:49, schrieb John Gordon: (This is mostly a style question, and perhaps one that has already been discussed elsewhere. If so, a pointer to that discussion will be appreciated!) When I started learning Python, I wrote a lot of methods that looked like this: def myMethod(self

Re: If/then style question

2010-12-16 Thread Grant Edwards
On 2010-12-16, John Gordon wrote: > (This is mostly a style question, and perhaps one that has already been > discussed elsewhere. If so, a pointer to that discussion will be > appreciated!) > > When I started learning Python, I wrote a lot of methods that looked like > this: > > > def myMethod

Re: If/then style question

2010-12-16 Thread Tim Harig
On 2010-12-16, John Gordon wrote: > I like this style more, mostly because it eliminates a lot of indentation. > > However I recall one of my college CS courses stating that "one entry, > one exit" was a good way to write code, and this style has lots of exits. So, take the good intentation from

Re: If/then style question

2010-12-16 Thread Ethan Furman
John Gordon wrote: (This is mostly a style question, and perhaps one that has already been discussed elsewhere. If so, a pointer to that discussion will be appreciated!) When I started learning Python, I wrote a lot of methods that looked like this: def myMethod(self, arg1, arg2): if so

If/then style question

2010-12-16 Thread John Gordon
(This is mostly a style question, and perhaps one that has already been discussed elsewhere. If so, a pointer to that discussion will be appreciated!) When I started learning Python, I wrote a lot of methods that looked like this: def myMethod(self, arg1, arg2): if some_good_condition:

Re: Is text processing with dicts a good use case for Python cross-compilers like Cython/Pyrex or ShedSkin?

2010-12-16 Thread Stefan Behnel
pyt...@bdurham.com, 16.12.2010 21:03: Is text processing with dicts a good use case for Python cross-compilers like Cython/Pyrex or ShedSkin? (I've read the cross compiler claims about massive increases in pure numeric performance). Cython is generally a good choice for string processing, simpl

pudb on windows (dependent upon unix only termios ?)

2010-12-16 Thread shearichard
Hi - I was just trying to install the Python debugger pudb (http:// pypi.python.org/pypi/pudb) and easy install fell over saying it couldn't find a module termios. It turns out termios is only for Unix (http://docs.python.org/library/ termios.html). Does anyone know of way around this ? Is there

Re: string identity and comparison

2010-12-16 Thread Arnaud Delobelle
Jean-Michel Pichavant writes: > Fellows, > > I'd like to illutrate the fact that comparing strings using identity > is, most of the time, a bad idea. However I'm searching a short > example of code that yields 2 differents object for the same string > content. > > id('foo') > 3082385472L > id('fo

Re: while True or while 1

2010-12-16 Thread Ethan Furman
Arnaud Delobelle wrote: Ethan Furman writes: ...I timed exec vs function, and found the function style to be about 200% faster... So it finished before it started? Hmmm Let me check my calculator... . . . Ah! Okay, that was 200x faster. :) I think -- it was a few months ago no

Re: Added Python, WSGI to XAMPP

2010-12-16 Thread Gerry Reno
On 12/16/2010 04:36 AM, Octavian Rasnita wrote: > From: "Ian Kelly" > > On Mon, Dec 13, 2010 at 5:58 PM, Gerry Reno wrote: > >> The VIEW is the bits that stream out of the webserver back to the users >> browser. >> > Why only to the user's browser? A web app could also offer the results

Re: while True or while 1

2010-12-16 Thread Terry Reedy
On 12/16/2010 7:23 AM, Steve Holden wrote: On 12/16/2010 5:44 AM, BartC wrote: One these is 30% faster than the other. That's an appreciable difference, which you can't really just dismiss. And you can't tell what the overall effect on a program will be: perhaps the loop will be in a library

Re: while True or while 1

2010-12-16 Thread Arnaud Delobelle
Ethan Furman writes: > ...I timed exec vs function, and found the function style to be about > 200% faster... So it finished before it started? -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Is text processing with dicts a good use case for Python cross-compilers like Cython/Pyrex or ShedSkin?

2010-12-16 Thread python
Is text processing with dicts a good use case for Python cross-compilers like Cython/Pyrex or ShedSkin? (I've read the cross compiler claims about massive increases in pure numeric performance). I have 3 use cases I'm considering for Python-to-C++ cross-compilers for generating 32-bit Python exten

Re: Python creates "locked" temp dir

2010-12-16 Thread utabintarbo
FWIW, I got around the issue with some samba mount options. They still show as 0700, but I, or anybody elsefor that matter, can still access them. Computers are weird. :P Thanks to all who responded. :) On Dec 10, 2:57 pm, Alex Willmer wrote: > On Dec 8, 6:26 pm, Christian Heimes wrote: > > >

Re: O'Reilly Python Certification

2010-12-16 Thread Steve Holden
Each lesson required you to complete a practical assignment. You submit these assignments for evaluation, and do not proceed to the next lesson until your assignment reaches a satisfactory standard. Thus, less experienced students will tend to have more interaction with their tutors. A class will

Re: O'Reilly Python Certification

2010-12-16 Thread Matty Sarro
So how exactly does the class work? Is it like an elementary CS class where you have a teacher, assignments, etc. Or is it more like a guided tour through the O'Reilly Python book/cookbook? On Thu, Dec 16, 2010 at 10:40 AM, Ethan Furman wrote: > Please don't top-post.  :) > > Nitin Pawar wrote: >

Re: Extending Thunderbird mail client with Python

2010-12-16 Thread mixedpuppy
On Nov 11, 11:48 pm, John Bond wrote: > Anyone have any experience with this, ideally using Python 3? > > I'd like to sync my Thunderbird contacts with various things including > my mobile phone. Of course, I want to do it with Python! I've seen some > stuff around, eg. an XPI that provides Python

ANN: PyGUI 2.3.2

2010-12-16 Thread Greg Ewing
PyGUI 2.3.2 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ This version fixes a problem in Cocoa whereby the coordinate system for drawing in a Pixmap was upside down, and corrects a slight mistake in the Canvas documentation. What is PyGUI? -- PyGUI is a

Re: How to pop the interpreter's stack?

2010-12-16 Thread Robert Kern
On 12/16/10 10:23 AM, Steven D'Aprano wrote: On Thu, 16 Dec 2010 07:29:25 -0800, Ethan Furman wrote: Tim Arnold wrote: "Ethan Furman" wrote in message news:mailman.4.1292379995.6505.python-l...@python.org... kj wrote: The one thing I don't like about this strategy is that the tracebacks of

Re: How to pop the interpreter's stack?

2010-12-16 Thread Steven D'Aprano
On Thu, 16 Dec 2010 07:29:25 -0800, Ethan Furman wrote: > Tim Arnold wrote: >> "Ethan Furman" wrote in message >> news:mailman.4.1292379995.6505.python-l...@python.org... >>> kj wrote: The one thing I don't like about this strategy is that the tracebacks of exceptions raised during the

Re: string identity and comparison

2010-12-16 Thread bruno.desthuilli...@gmail.com
On 16 déc, 15:53, Jean-Michel Pichavant wrote: > Mel wrote: > > Jean-Michel Pichavant wrote: > > >> Fellows, > > >> I'd like to illutrate the fact that comparing strings using identity is, > >> most of the time, a bad idea. However I'm searching a short example of > >> code that yields 2 different

Re: string identity and comparison

2010-12-16 Thread bruno.desthuilli...@gmail.com
On 16 déc, 15:52, Jean-Michel Pichavant wrote: > bruno.desthuilli...@gmail.com wrote: > > On 16 d c, 12:55, Jean-Michel Pichavant > > wrote: > > >> id('foo') > >> 3082385472L > >> id('foo') > >> 3082385472L > > >> Anyone has that kind of code ? > > > 2 points: > > > 1- an id is only valid for the

Re: O'Reilly Python Certification

2010-12-16 Thread Ethan Furman
Please don't top-post. :) Nitin Pawar wrote: Can someone provide any links or any starting points on how to apply and what are the prerequisites http://www.oreillyschool.com/certificates/python-programming.php No prerequisites that I could see, and currently they are running a 25% discount

Re: while True or while 1

2010-12-16 Thread Ethan Furman
BartC wrote: "Steve Holden" wrote in message news:mailman.462.1292214062.2649.python-l...@python.org... On 12/12/2010 2:32 PM, Christian Heimes wrote: Am 12.12.2010 19:31, schrieb Steve Holden: $ python -m timeit -n20 -- "i = 0" "while 1:" "i+=1" "if i == 100: break" 20 loops, best

Re: How to pop the interpreter's stack?

2010-12-16 Thread Ethan Furman
Tim Arnold wrote: "Ethan Furman" wrote in message news:mailman.4.1292379995.6505.python-l...@python.org... kj wrote: The one thing I don't like about this strategy is that the tracebacks of exceptions raised during the execution of __pre_spam include one unwanted stack level (namely, the one c

Re: string identity and comparison

2010-12-16 Thread Jean-Michel Pichavant
Mel wrote: Jean-Michel Pichavant wrote: Fellows, I'd like to illutrate the fact that comparing strings using identity is, most of the time, a bad idea. However I'm searching a short example of code that yields 2 differents object for the same string content. id('foo') 3082385472L id('foo')

Re: string identity and comparison

2010-12-16 Thread Jean-Michel Pichavant
bruno.desthuilli...@gmail.com wrote: On 16 déc, 12:55, Jean-Michel Pichavant wrote: id('foo') 3082385472L id('foo') 3082385472L Anyone has that kind of code ? 2 points: 1- an id is only valid for the lifetime of a given object - when the object has been collected, the id can be reu

Re: ANN: Shed Skin 0.7

2010-12-16 Thread python
Mark, Congratulations on your latest release! How well do python extension modules created with ShedSkin work with applications that expose a GUI, eg. Tkinter or wxPython apps? Can ShedSkin code be run in a thread and communicate with the main interpreter thread through a Queue or Lock? (Or shou

Re: string identity and comparison

2010-12-16 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Fellows, I'd like to illutrate the fact that comparing strings using identity is, most of the time, a bad idea. However I'm searching a short example of code that yields 2 differents object for the same string content. id('foo') 3082385472L id('foo') 3082385472L

Re: string identity and comparison

2010-12-16 Thread Mel
Jean-Michel Pichavant wrote: > Fellows, > > I'd like to illutrate the fact that comparing strings using identity is, > most of the time, a bad idea. However I'm searching a short example of > code that yields 2 differents object for the same string content. > > id('foo') > 3082385472L > id('foo'

Re: Extending Thunderbird mail client with Python

2010-12-16 Thread Anssi Saari
John Bond writes: > Anyone have any experience with this, ideally using Python 3? I don't but there is a great need to have a working SyncML client for Thunderbird. Funambol used to have one available, but it has crashing problems with Thunderbird 3 for some people. The existing extension was do

Re: string identity and comparison

2010-12-16 Thread Peter Otten
Peter Otten wrote: > Steve Holden wrote: > >> On 12/16/2010 6:55 AM, Jean-Michel Pichavant wrote: >>> Fellows, >>> >>> I'd like to illutrate the fact that comparing strings using identity is, >>> most of the time, a bad idea. However I'm searching a short example of >>> code that yields 2 differ

Re: string identity and comparison

2010-12-16 Thread Peter Otten
Steve Holden wrote: > On 12/16/2010 6:55 AM, Jean-Michel Pichavant wrote: >> Fellows, >> >> I'd like to illutrate the fact that comparing strings using identity is, >> most of the time, a bad idea. However I'm searching a short example of >> code that yields 2 differents object for the same strin

ANN: Shed Skin 0.7

2010-12-16 Thread Mark Dufour
Hi all, I have just released Shed Skin 0.7, an optimizing (restricted-)Python-to-C++ compiler. It comes with lots of minor fixes and some optimizations, a new Windows package (which includes GCC 4.5), and two nice new examples, for a total of 52 examples at around 14,000 lines (sloccount). Please

[Fwd: Re: Calling function from another module]

2010-12-16 Thread craf
- Mensaje reenviado > De: Peter Otten <__pete...@web.de> > Para: python-list@python.org > Asunto: Re: Calling function from another module > Fecha: Thu, 16 Dec 2010 13:16:30 +0100 > Grupos de noticias: comp.lang.python > > craf wrote: > > > Hi. > > > > The query code is as follo

Re: string identity and comparison

2010-12-16 Thread Steve Holden
On 12/16/2010 6:55 AM, Jean-Michel Pichavant wrote: > Fellows, > > I'd like to illutrate the fact that comparing strings using identity is, > most of the time, a bad idea. However I'm searching a short example of > code that yields 2 differents object for the same string content. > > id('foo') >

Re: while True or while 1

2010-12-16 Thread Steve Holden
On 12/16/2010 5:44 AM, BartC wrote: >> On 12/12/2010 2:32 PM, Christian Heimes wrote: >>> Am 12.12.2010 19:31, schrieb Steve Holden: >>> $ python -m timeit -n20 -- "i = 0" "while 1:" "i+=1" "if i == >>> 100: break" >>> 20 loops, best of 3: 89.7 msec per loop >>> $ python -m timeit -n20

Re: Calling function from another module

2010-12-16 Thread Peter Otten
craf wrote: > Hi. > > The query code is as follows: > > -- > import Tkinter > import tkMessageBox > > > class App: > def __init__(self, master): > master.protocol("WM_DELETE_WINDOW",quit) > > > def quit(): > if tkMessageBox.

Re: string identity and comparison

2010-12-16 Thread bruno.desthuilli...@gmail.com
On 16 déc, 12:55, Jean-Michel Pichavant wrote: > Fellows, > > I'd like to illutrate the fact that comparing strings using identity is, > most of the time, a bad idea. However I'm searching a short example of > code that yields 2 differents object for the same string content. > > id('foo') > 308238

Re: string identity and comparison

2010-12-16 Thread André
On Thursday, December 16, 2010 7:55:20 AM UTC-4, jeanmichel wrote: > Fellows, > > I'd like to illutrate the fact that comparing strings using identity is, > most of the time, a bad idea. However I'm searching a short example of > code that yields 2 differents object for the same string content.

string identity and comparison

2010-12-16 Thread Jean-Michel Pichavant
Fellows, I'd like to illutrate the fact that comparing strings using identity is, most of the time, a bad idea. However I'm searching a short example of code that yields 2 differents object for the same string content. id('foo') 3082385472L id('foo') 3082385472L Anyone has that kind of code

Re: while True or while 1

2010-12-16 Thread BartC
"Steve Holden" wrote in message news:mailman.462.1292214062.2649.python-l...@python.org... On 12/12/2010 2:32 PM, Christian Heimes wrote: Am 12.12.2010 19:31, schrieb Steve Holden: $ python -m timeit -n20 -- "i = 0" "while 1:" "i+=1" "if i == 100: break" 20 loops, best of 3: 89.7 ms

Re: Added Python, WSGI to XAMPP

2010-12-16 Thread Octavian Rasnita
From: "Ian Kelly" On Mon, Dec 13, 2010 at 5:58 PM, Gerry Reno wrote: > The VIEW is the bits that stream out of the webserver back to the users > browser. Why only to the user's browser? A web app could also offer the results in formats that can be accessed with something else than a browser.

Re: O'Reilly Python Certification

2010-12-16 Thread Nitin Pawar
Can someone provide any links or any starting points on how to apply and what are the prerequisites Thanks, Nitin On Thu, Dec 16, 2010 at 12:18 PM, Steve Holden wrote: > On 12/15/2010 4:21 PM, Stefan Sonnenberg-Carstens wrote: > > Am 15.12.2010 22:11, schrieb Steve Holden: > >> On 12/15/2010 3:

Re: Dealing with pywin32 on Linux

2010-12-16 Thread Benedict Verheyen
On 15/12/2010 16:54, Stefan Sonnenberg-Carstens wrote: > Just change to LDAP as authentication method. > Even Active Directory offers LDAP (w/o SSL), and there > are modules to interact with LDAP using python. > And, it is platform indipendent. > > See here: http://www.python-ldap.org/ > > I've