Re: True lists in python?

2010-12-18 Thread Dmitry Groshev
On Dec 19, 9:48 am, Vito 'ZeD' De Tullio wrote: > Dmitry Groshev wrote: > > Is there any way to use a true lists (with O(c) insertion/deletion and > > O(n) search) in python? For example, to make things like reversing > > part of the list with a constant time. > > if you're interested just in "rev

Re: True lists in python?

2010-12-18 Thread Vito 'ZeD' De Tullio
Dmitry Groshev wrote: > Is there any way to use a true lists (with O(c) insertion/deletion and > O(n) search) in python? For example, to make things like reversing > part of the list with a constant time. if you're interested just in "reverse" a collection maybe you can take a look at the deque[

Re: True lists in python?

2010-12-18 Thread Dmitry Groshev
On Dec 19, 9:18 am, Dmitry Groshev wrote: > Is there any way to use a true lists (with O(c) insertion/deletion and > O(n) search) in python? For example, to make things like reversing > part of the list with a constant time. I forgot to mention that I mean *fast* lists. It's trivial to do things

True lists in python?

2010-12-18 Thread Dmitry Groshev
Is there any way to use a true lists (with O(c) insertion/deletion and O(n) search) in python? For example, to make things like reversing part of the list with a constant time. -- http://mail.python.org/mailman/listinfo/python-list

Re: If/then style question

2010-12-18 Thread Carl Banks
On Dec 17, 12:23 am, Steven D'Aprano wrote: > 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 mu

Re: If/then style question

2010-12-18 Thread Steven D'Aprano
On Sat, 18 Dec 2010 12:29:31 +0100, Francesco wrote: [...] > I agree to your point, but I'm afraid you chose a wrong example (AFAIK, > and that's not much). Sure, the second version of function(arg) is much > more readable, but why do you think the first one would do "*lots* of > unnecessary work

Re: Serialize my class as JSON causes "__init__() got an unexpected keyword argument 'indent'" ?

2010-12-18 Thread Terry Reedy
On 12/18/2010 6:32 AM, shearichard wrote: Brilliant - thank you very much. Now that you've explained it I can see why the documentation is written the way it is ! Before I saw your example I thought the documentation was a bit strange but I can see now what it was trying to tell me ! If you h

Re: Added Python, WSGI to XAMPP

2010-12-18 Thread Gerry Reno
On 12/17/2010 02:36 PM, Daniel Fetchinson wrote: >> 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... >>>

Re: Newbie question about importing modules.

2010-12-18 Thread Tim Roberts
cronoklee wrote: > >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

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

2010-12-18 Thread Nobody
On Fri, Dec 17, 2010 at 17:57, 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 = subproce

Re: Serialize my class as JSON causes "__init__() got an unexpected keyword argument 'indent'" ?

2010-12-18 Thread shearichard
On Dec 18, 11:30 pm, Peter Otten <__pete...@web.de> wrote: > shearichard wrote: > > Hi - I've got a straightforward class I want to serialize as JSON > > (actually I want to a serialize a list of them but I believe that's > > irrelevant). > > > I've subclassed JSONEncoder and defined my own version

Re: If/then style question

2010-12-18 Thread Francesco
On 17/12/2010 0.51, Steven D'Aprano wrote: Don't get me wrong... spaghetti code is*bad*. But there are other ways of writing bad code too, and hanging around inside a function long after you've finished is also bad: def function(arg): done = False do_something() if some_condition:

Re: Serialize my class as JSON causes "__init__() got an unexpected keyword argument 'indent'" ?

2010-12-18 Thread Peter Otten
shearichard wrote: > Hi - I've got a straightforward class I want to serialize as JSON > (actually I want to a serialize a list of them but I believe that's > irrelevant). > > I've subclassed JSONEncoder and defined my own version of the > 'default' method ( based upon what I read at > http://doc

Serialize my class as JSON causes "__init__() got an unexpected keyword argument 'indent'" ?

2010-12-18 Thread shearichard
Hi - I've got a straightforward class I want to serialize as JSON (actually I want to a serialize a list of them but I believe that's irrelevant). I've subclassed JSONEncoder and defined my own version of the 'default' method ( based upon what I read at http://docs.python.org/library/json.html )