Re: Creating custom types from C code

2010-12-17 Thread Stefan Behnel
Eric Frederich, 17.12.2010 23:58: I have an extension module for a 3rd party library in which I am wrapping some structures. My initial attempt worked okay on Windows but failed on Linux. I was doing it in two parts. The first part on the C side of things I was turning the entire structure into a

Re: If/then style question

2010-12-17 Thread Steven D'Aprano
On Fri, 17 Dec 2010 17:26:08 +, Grant Edwards wrote: > Give me code that's easy-to-read and doesn't work rather code that works > and can't be read any day. Well, in that case, you'll love my new operating system, written in 100% pure Python: [start code] print("this is an operating system"

Re: If/then style question

2010-12-17 Thread Steven D'Aprano
On Fri, 17 Dec 2010 10:53:45 -0500, Steve Holden wrote about for...else: > This construct appears to be unpopular in actual use, and when it comes > up in classes and seminars there is always interesting debate as people > discuss potential uses and realise there are useful applications. Yes, I f

PySide: Python for Qt version 1.0.0~beta2 "Mineshaft gap" released

2010-12-17 Thread Matti Airas
The PySide team is happy to announce the second beta release of PySide: Python for Qt. New versions of some of the PySide toolchain components (API Extractor and Shiboken) have been released as well. This is a source code release only; we hope our community packagers will be providing provide

Re: Read / Write OpenOffice SpreadSheet ?

2010-12-17 Thread Hans-Peter Jansen
On Friday 17 December 2010, 02:07:07 Torsten Mohr wrote: > 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? http://ooopy.sourceforge.net/ Pete -- http://mail.python.

Re: Read / Write OpenOffice SpreadSheet ?

2010-12-17 Thread Terry Reedy
On 12/17/2010 4:19 AM, Torsten Mohr wrote: Hello, There is no package needed to read or write the new open document files. The files are merely a jar archive containing XML files. You can open and update them using jar as a subprocess and manipulate the XML files using your favorite XML librar

Re: Odd listcomp behaviour

2010-12-17 Thread MRAB
On 17/12/2010 23:08, Emile van Sebille wrote: Does anyone else consider this a bug? Python 2.6.2 (r262:71600, Jun 16 2009, 11:09:39) [GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2 Type "help", "copyright", "credits" or "license" for more information. ---1--- >>> skippedords = '1,2,3,4,5' >

Re: subprocess.Popen() and a .msi installer

2010-12-17 Thread Benjamin Kaplan
On Fri, Dec 17, 2010 at 5:57 PM, Sebastian Alonso wrote: > Hey everyone, I'm working on a script which uses subprocess to launch a > bunch of installers, but I'm getting problems with .msi installers although > .exe ones work fine. The output I get is this: > import subprocess p = subpro

Re: Odd listcomp behaviour

2010-12-17 Thread Emile van Sebille
On 12/17/2010 3:17 PM Emile van Sebille said... On 12/17/2010 3:08 PM Emile van Sebille said... Does anyone else consider this a bug? Hmmm... looks like it's split that I've got the issue with... Nevermind... if it's documented it's not a bug, right? Hrrmph. Emile str.split([sep[, maxs

Re: Odd listcomp behaviour

2010-12-17 Thread Ethan Furman
Emile van Sebille wrote: Does anyone else consider this a bug? Python 2.6.2 (r262:71600, Jun 16 2009, 11:09:39) [GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2 Type "help", "copyright", "credits" or "license" for more information. ---1--- >>> skippedords = '1,2,3,4,5' >>> ['10%s' % ii for i

Re: Odd listcomp behaviour

2010-12-17 Thread Emile van Sebille
On 12/17/2010 3:08 PM Emile van Sebille said... Does anyone else consider this a bug? Hmmm... looks like it's split that I've got the issue with... >>> "this is a test".split() ['this', 'is', 'a', 'test'] >>> "this is a test".split(' ') ['this', 'is', 'a', 'test'] >>> "".split(' ') [''] >>> "

Odd listcomp behaviour

2010-12-17 Thread Emile van Sebille
Does anyone else consider this a bug? Python 2.6.2 (r262:71600, Jun 16 2009, 11:09:39) [GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2 Type "help", "copyright", "credits" or "license" for more information. ---1--- >>> skippedords = '1,2,3,4,5' >>> ['10%s' % ii for ii in skippedords.split(',')]

Creating custom types from C code

2010-12-17 Thread Eric Frederich
Hello, I have an extension module for a 3rd party library in which I am wrapping some structures. My initial attempt worked okay on Windows but failed on Linux. I was doing it in two parts. The first part on the C side of things I was turning the entire structure into a char array. The second part

subprocess.Popen() and a .msi installer

2010-12-17 Thread Sebastian Alonso
Hey everyone, I'm working on a script which uses subprocess to launch a bunch of installers, but I'm getting problems with .msi installers although .exe ones work fine. The output I get is this: >>> import subprocess >>> p = subprocess.Popen('python.msi') Traceback (most recent call last): File ""

Re: class inheritance

2010-12-17 Thread JLundell
On Saturday, March 13, 2010 9:03:36 AM UTC-8, Jonathan Lundell wrote: > I've got a subclass of fractions.Fraction called Value; it's a mostly > trivial class, except that it overrides __eq__ to mean 'nearly equal'. > However, since Fraction's operations result in a Fraction, not a > Value, I end up

Help with threading.local use in python-memcache module.

2010-12-17 Thread Sean Reifschneider
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Some time ago I accepted a patch to base the memcache client module on the threading.local class. Now I've got some reports of issues with this that I'm not sure what the best way to resolve is. Bug #530229: https://bugs.launchpad.net/python-memcache

Re: Added Python, WSGI to XAMPP

2010-12-17 Thread Daniel Fetchinson
> How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP > >>> >>> Maybe, if there's no Zope. Or we'll run away screaming... >> >> That is rather pathetically true... >> >> Ah well, each to their own... >> >> Chris >> > What

Re: If/then style question

2010-12-17 Thread Kev Dwyer
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: PyUNO [Was: Read / Write OpenOffice SpreadSheet ?]

2010-12-17 Thread Stef Mientki
On 17-12-2010 17:02, Adam Tauno Williams wrote: > On Fri, 2010-12-17 at 10:19 +0100, Torsten Mohr wrote: >> Thanks, i read about it but as i understood it, UNO needs Python 2.3.x and >> i'd like to base on something actual. > I do not *believe* this is true. > >

Re: PyUNO [Was: Read / Write OpenOffice SpreadSheet ?]

2010-12-17 Thread Tim Harig
On 2010-12-17, Adam Tauno Williams wrote: > I would strongly recommend against floundering about in OOo's very > complex XML files - it is trivially easy to render a document unusable. I do it all the time and have never had a problem. I don't generate the documents from scratch; I generate a te

RE: If/then style question

2010-12-17 Thread Rob Richardson
-Original Message- You have outlined what happens when cond1 and cond2 both evaluate to True -- what happens if, say, cond2 evaluates to False? - I reply And the light goes on! (And palm strikes forehead.) I was thinking that the error we were processing was raised by

Re: If/then style question

2010-12-17 Thread Grant Edwards
On 2010-12-16, Steven D'Aprano wrote: > 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

Re: If/then style question

2010-12-17 Thread Grant Edwards
On 2010-12-16, Stefan Sonnenberg-Carstens wrote: > The advantage in latter case is fewer operations, because you can > skip the assignments, and it is more readable. > > The "one entry, one exit" is an advice. Not a law. > Your code is OK. > > As long as it works ;-) Even that last bit isn't th

Re: If/then style question

2010-12-17 Thread python
> I now remember this idiom as the "break else" construct: either the loop > breaks, or the "else:" suite is executed. A perfect description. Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: If/then style question

2010-12-17 Thread Arnaud Delobelle
Tim Golden writes: > On 17/12/2010 15:53, Steve Holden wrote: > > [... snip example of for-else ...] > >> This construct appears to be unpopular in actual use, and when it comes >> up in classes and seminars there is always interesting debate as people >> discuss potential uses and realise there

Re: If/then style question

2010-12-17 Thread Mark Wooding
Steve Holden writes: > I think the choice of keyword is probably not Guido's crowning > language achievement, I remember the behaviour by considering a typical application: for thing in things: if shinyp(thing): break else: raise DullError, 'nothi

Re: If/then style question

2010-12-17 Thread Steve Holden
On 12/17/2010 11:13 AM, Tim Golden wrote: > On 17/12/2010 15:53, Steve Holden wrote: > > [... snip example of for-else ...] > >> This construct appears to be unpopular in actual use, and when it comes >> up in classes and seminars there is always interesting debate as people >> discuss potential

Re: If/then style question

2010-12-17 Thread Ethan Furman
Rob Richardson wrote: My thanks for pointing out the existence of the else: suite in the for statement. However, I remain confused. For reference, here's the original code: def myMethod(): for condition, exitCode in [ (cond1, 'error1'), (cond2, 'very bad error'),

Re: PyUNO [Was: Read / Write OpenOffice SpreadSheet ?]

2010-12-17 Thread Stefan Behnel
Adam Tauno Williams, 17.12.2010 17:02: On Fri, 2010-12-17 at 10:19 +0100, Torsten Mohr wrote: Thanks, i read about it but as i understood it, UNO needs Python 2.3.x and i'd like to base on something actual. I do not *believe* this is true. for ins

Re: If/then style question

2010-12-17 Thread Paul Rubin
Jean-Michel Pichavant writes: > What about, > > def myMethod(): >for condition, exitCode in [ >(cond1, 'error1'), >(cond2, 'very bad error'), >]: >if not condition: >break >else: > do_some_usefull_stuff() # executed only if the we never

ANN: Shed Skin 0.7

2010-12-17 Thread Mark Dufour
hi malcolm, Congratulations on your latest release! > thanks! :D > > How well do python extension modules created with ShedSkin work with > applications that expose a GUI, eg. Tkinter or wxPython apps? > quite well I think, but there are some limitations you probably want to be aware of. these

Re: If/then style question

2010-12-17 Thread Tim Golden
On 17/12/2010 15:53, Steve Holden wrote: [... snip example of for-else ...] This construct appears to be unpopular in actual use, and when it comes up in classes and seminars there is always interesting debate as people discuss potential uses and realise there are useful applications. I use t

RE: If/then style question

2010-12-17 Thread Rob Richardson
My thanks for pointing out the existence of the else: suite in the for statement. However, I remain confused. For reference, here's the original code: > def myMethod(): > for condition, exitCode in [ > (cond1, 'error1'), > (cond2, 'very bad error'), > ]: >

PyUNO [Was: Read / Write OpenOffice SpreadSheet ?]

2010-12-17 Thread Adam Tauno Williams
On Fri, 2010-12-17 at 10:19 +0100, Torsten Mohr wrote: > Thanks, i read about it but as i understood it, UNO needs Python 2.3.x and > i'd like to base on something actual. I do not *believe* this is true. for instance is Python 2.6 and uses PyUNO. I

Re: If/then style question

2010-12-17 Thread Steve Holden
On 12/17/2010 9:38 AM, Steven D'Aprano wrote: > On Fri, 17 Dec 2010 09:09:49 -0500, Rob Richardson wrote: > > >> First, just to clarify, I don't think the indentation I saw was what was >> originally posted. The "else" must be indented to match the "if", and >> the two statements under "else" ar

Re: Read / Write OpenOffice SpreadSheet ?

2010-12-17 Thread Stefan Behnel
Torsten Mohr, 17.12.2010 02:07: 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? Have you looked through the relevant PyPI packages? http://pypi.python.org/pypi?%3Aaction=searc

Re: How to pop the interpreter's stack?

2010-12-17 Thread Robert Kern
On 12/16/10 6:33 PM, Steven D'Aprano wrote: 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

Re: Newbie question about importing modules.

2010-12-17 Thread cronoklee
Hey thanks for the help fellas. The links were helpful and the pyExe program looks great. I might well end up using this. I'm still a little confused as to how the directory structure works. PIL (http://www.pythonware.com/products/pil/#pil117), for example comes packed in a folder called Imagin

Re: If/then style question

2010-12-17 Thread David Robinow
On Thu, Dec 16, 2010 at 6:51 PM, Steven D'Aprano wrote: ... > Functions always have one entry. The only way to have multiple entry > points is if the language allows you to GOTO into the middle of a > function, and Python sensibly does not allow this. The "one entry, one > exit" rule comes from th

Re: If/then style question

2010-12-17 Thread Jean-Michel Pichavant
Rob Richardson wrote: -Original Message- What about, def myMethod(): for condition, exitCode in [ (cond1, 'error1'), (cond2, 'very bad error'), ]: if not condition: break else: do_some_usefull_stuff() # executed only if the

Re: If/then style question

2010-12-17 Thread Steven D'Aprano
On Fri, 17 Dec 2010 09:09:49 -0500, Rob Richardson wrote: > First, just to clarify, I don't think the indentation I saw was what was > originally posted. The "else" must be indented to match the "if", and > the two statements under "else" are in the else block. The return > statement is indente

RE: If/then style question

2010-12-17 Thread Rob Richardson
-Original Message- What about, def myMethod(): for condition, exitCode in [ (cond1, 'error1'), (cond2, 'very bad error'), ]: if not condition: break else: do_some_usefull_stuff() # executed only if the we never hit the break

Re: If/then style question

2010-12-17 Thread Jean-Michel Pichavant
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 s

Re: Newbie question about importing modules.

2010-12-17 Thread shearichard
On Dec 17, 4:42 pm, cronoklee wrote: > 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

Re: Read / Write OpenOffice SpreadSheet ?

2010-12-17 Thread Torsten Mohr
Hello, > There is no package needed to read or write the new open document files. > The files are merely a jar archive containing XML files. You can open > and update them using jar as a subprocess and manipulate the XML files > using your favorite XML libraries DOM/SAX/XPath/Etree/etc. thanks f

Re: Newbie question about importing modules.

2010-12-17 Thread Tim Roberts
cronoklee wrote: > >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. That's not really t

Re: If/then style question

2010-12-17 Thread Steven D'Aprano
On Thu, 16 Dec 2010 20:32:29 -0800, Carl Banks wrote: > Even without the cleanup issue, sometimes you want to edit a function to > affect all return values somehow. If you have a single exit point you > just make the change there; if you have mulitple you have to hunt them > down and change all o