Re: sys.argv is munging my command line options

2007-08-29 Thread Arnau Sanchez
Chris Allen escribió: > action key=value key=value... > > Where action is a required string (ie. 'backup', 'init', 'restore', > etc) and the program can accept one or more key value pairs. I know > this syntax isn't standard, but I think it works great for my program > as each key can override a

Re: IDE for Python

2007-08-29 Thread Stefan Behnel
Eric CHAO wrote: > I think many python developers don't need such an IDE actually. Just > like Ruby guys, they use a powerful editor, for example, Textmate, > instead of all-in-one IDE. It's quick and direct. True. However, some use neither an editor nor an IDE but Emacs. Stefan -- http://mail.p

ANNOUNCE: Spiff Workflow 0.0.2

2007-08-29 Thread Samuel
Introduction Spiff Workflow is a library implementing a framework for workflows. It is based on http://www.workflowpatterns.com and implemented in pure Python. Spiff Workflow is part of the Spiff platform, which aims to produce a number of generic libraries generally needed in enterp

Re: Creating a multi-tier client/server application

2007-08-29 Thread David Bolen
Jeff <[EMAIL PROTECTED]> writes: > reasons, not the least of which is that I've been working almost > entirely on web apps for the past few years, and I am getting mighty > sick of it. A lot of that is due to the language (PHP, which I have > since grown to hate) I had to use. I've worked on a s

Re: Unzip: Memory Error

2007-08-29 Thread David Bolen
mcl <[EMAIL PROTECTED]> writes: > I am trying to unzip an 18mb zip containing just a single 200mb file > and I get a Memory Error. When I run the code on a smaller file 1mb > zip, 11mb file, it works fine. (...) > def unzip_file_into_dir(file, dir): > #os.mkdir(dir, 0777) > zfobj = zi

Re: Accessing docstrings at runtime?

2007-08-29 Thread Kenneth Love
On 08/29/07, Chris Mellon <[EMAIL PROTECTED]> wrote: > On 8/29/07, Kenneth Love <[EMAIL PROTECTED]> wrote: >> How do I print the docstring for a class property? >> >> [[[ SNIP EXAMPLE ]]] >> >> What am I doing wrong? >> > > You're looking at an instance, not at the class. y.x is going through > the

Re: cgi

2007-08-29 Thread Fabio Z Tessitore
Are you sure your script is in the right dir? On my home computer, php script will work in /var/www but my python script need an other dir to work properly (i don't remember which now ;-)) bye -- http://mail.python.org/mailman/listinfo/python-list

Short, crazy example: list-derived class, with __iadd__

2007-08-29 Thread Moon
class Vec(list): def __init__(self): list.__init__(self, [0.0, 0.0]) def __iadd__(self, other): assert isinstance(other, Vec) self[0] += other[0] self[1] += other[1] print "right now, v is: ", self, " as you'd expect" v = Vec() w = Vec() w[0] = 1.0

Re: Haskell like (c:cs) syntax

2007-08-29 Thread Stefan Niemann
Thanks for all the good answers. In fact the `Extended Iterable Unpacking' is exactly what I was looking for. Ok, my main aspect of writing head, *tail = seq instead of head, tail = seq[0], seq[1:] is the syntactic sugar. As mentioned in the PEP this may also be faster when iterables

RE: copying files

2007-08-29 Thread Brian McCann
Hi Ricardo, what do the + signs do? From: Ricardo Aráoz [mailto:[EMAIL PROTECTED] Sent: Wed 8/29/2007 2:51 PM To: Brian McCann Cc: [email protected] Subject: Re: copying files Brian McCann wrote: > Hi, > > with the code

Re: Short, crazy example: list-derived class, with __iadd__ <- nevermind, me == idiot

2007-08-29 Thread Moon
__iadd__ is supposed to /return/ something, most likely self. My bad. On Wed, 29 Aug 2007 20:49:59 +, Moon wrote: > class Vec(list): > def __init__(self): > list.__init__(self, [0.0, 0.0]) > > def __iadd__(self, other): > assert isinstance(other, Vec) > sel

Re: cgi

2007-08-29 Thread Gigs_
Fabio Z Tessitore wrote: > Are you sure your script is in the right dir? > > On my home computer, php script will work in /var/www but my python > script need an other dir to work properly (i don't remember which now ;-)) > > bye > i think that it is in right dir because other script in same di

Re: Short, crazy example: list-derived class, with __iadd__

2007-08-29 Thread Marshall T. Vandegrift
Moon <[EMAIL PROTECTED]> writes: > class Vec(list): > def __init__(self): > list.__init__(self, [0.0, 0.0]) > > def __iadd__(self, other): > assert isinstance(other, Vec) > self[0] += other[0] > self[1] += other[1] > print "right now, v is: ", self,

Re: cgi

2007-08-29 Thread Gigs_
Gigs_ wrote: > Fabio Z Tessitore wrote: >> Are you sure your script is in the right dir? >> >> On my home computer, php script will work in /var/www but my python >> script need an other dir to work properly (i don't remember which now >> ;-)) >> >> bye >> > i think that it is in right dir becaus

Thread issue

2007-08-29 Thread James Matthews
Hi I have a program that downloads webpages. The webpages are stored in a list and i make each has it's own thread that downloads it. Sometimes the threads exit (because urlopen() throws an exception) Now the question is how can i recover from this thread failing Example Code from urllib import

Re: status of Programming by Contract (PEP 316)?

2007-08-29 Thread Steve Holden
Chris Mellon wrote: > On 8/29/07, Russ <[EMAIL PROTECTED]> wrote: [...] >> If you are >> programming something that doesn't really need to be correct, than you >> probably don't need it. But if you really need (or want) your software >> to be correct and reliable as possible, I think you you should

Re: copying files

2007-08-29 Thread Ricardo Aráoz
Brian McCann wrote: > > > > Hi Ricardo, > > what do the + signs do? > Add the different strings. You had 'm' and 'TEST_HOME' inside a string, so they would be taken as characters and not variables. >>> TEST_HOME = "/v01/test_home" >>> m = "./lib" >>> "cp -r " +

Re: re compiled object result caching?

2007-08-29 Thread Steve Holden
Dan wrote: > I find myself often using regular expressions in the following > pattern: > > foo_re = re.compile(r"foo(bar)") > # . . . > re_result = foo_re.search(line) > if re_result: > bar = re_result.group(1) > # . . . > > But, I keep thinking this is awkward, and I would kind of like t

Re: re compiled object result caching?

2007-08-29 Thread Dan Stromberg - Datallegro
On Wed, 29 Aug 2007 17:45:36 -0400, Steve Holden wrote: > Dan wrote: >> foo_re = re.compile(r"foo(bar)") >> # . . . >> if foo_re.search(line): >> foo_re.last_result().group(1) >> > If you wanted to implement this I don't really see why a method call is > necessary. It would surely only need

Re: Haskell like (c:cs) syntax

2007-08-29 Thread Erik Max Francis
Marco Mariani wrote: > Ricardo Aráoz ha scritto: > >> L = ['one', 'two', 'three', 'four', 'five'] >> >> print L[0]# This would be 'head' >> print L[1:] # This would be 'tail' >> >> Caution : L[0] and L[1:] are COPIES of the head and tail of the list. > > This might surprise people who see L

Re: cgi

2007-08-29 Thread Fabio Z Tessitore
Il Wed, 29 Aug 2007 23:11:53 +0200, Gigs_ ha scritto: > Gigs_ wrote: >> Fabio Z Tessitore wrote: >>> Are you sure your script is in the right dir? >>> >>> On my home computer, php script will work in /var/www but my python >>> script need an other dir to work properly (i don't remember which now >

Re: re compiled object result caching?

2007-08-29 Thread Marc 'BlackJack' Rintsch
On Wed, 29 Aug 2007 21:54:50 +, Dan Stromberg - Datallegro wrote: > I've long felt that publicly accessible attributes probably should be > syntactic sugared to look like accessor methods, a bit like how __add__ > ends up being + - so that if your attribute ever needs to become methods > (say,

Re: re compiled object result caching?

2007-08-29 Thread Steve Holden
Dan Stromberg - Datallegro wrote: > On Wed, 29 Aug 2007 17:45:36 -0400, Steve Holden wrote: > >> Dan wrote: >>> foo_re = re.compile(r"foo(bar)") >>> # . . . >>> if foo_re.search(line): >>> foo_re.last_result().group(1) >>> >> If you wanted to implement this I don't really see why a method call

Re: replacing xml elements with other elements using lxml

2007-08-29 Thread Ultrus
Stefan, I'm honored by your response. You are correct about the bad xml. I attempted to shorten the xml for this example as there are other tags unrelated to this issue in the mix. Based on your feedback, I was able to make following fully functional code using some different techniques: from lxm

Re: status of Programming by Contract (PEP 316)?

2007-08-29 Thread Dan Stromberg - Datallegro
On Tue, 28 Aug 2007 23:45:28 -0700, Russ wrote: > On Aug 28, 10:58 pm, Michele Simionato <[EMAIL PROTECTED]> > wrote: > >> Why do you think that would ad a strong positive capability? >> To me at least it seems a big fat lot of over-engineering, not >> needed in 99% of programs. In the remaining

Re: IDE for Python

2007-08-29 Thread Ben Finney
Stefan Behnel <[EMAIL PROTECTED]> writes: > Eric CHAO wrote: > > I think many python developers don't need such an IDE actually. Just > > like Ruby guys, they use a powerful editor, for example, Textmate, > > instead of all-in-one IDE. It's quick and direct. > > True. However, some use neither an

Re: status of Programming by Contract (PEP 316)?

2007-08-29 Thread Russ
> But it's always a good idea to make your software "correct and as > reliable as possible", isn't it? The problem is the external constraints > on the project. As the old saying goes: "Cheap, fast, reliable: choose > any two". If you are suggesting that "programming by contract" is not appropria

Re: Haskell like (c:cs) syntax

2007-08-29 Thread Carl Banks
On Tue, 28 Aug 2007 17:30:47 -0500, Erik Jones wrote: > On Aug 28, 2007, at 5:12 PM, Chris Mellon wrote: >> When working with lists, Python has a slice syntax (which is rather >> more powerful than Haskells limited head->tail linked list syntax) that >> you can use to chop a sequence up into variou

RE: copying files

2007-08-29 Thread Carsten Haese
On Wed, 2007-08-29 at 17:03 -0400, Brian McCann wrote: > what do the + signs do? Start here: http://docs.python.org/tut/ -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Is LOAD_GLOBAL really that slow?

2007-08-29 Thread Adam Olsen
It seems a common opinion that global access is much slower than local variable access. However, my benchmarks show a relatively small difference: ./python -m timeit -r 10 -v -s 'x = [None] * 1 def foo(): for i in x: list; list; list; list; list; list; list; list; list; list' 'foo()' 10

How to use os.putenv() ?

2007-08-29 Thread google
>>> >>> import os >>> >>> os.environ['PATH'] 'C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\System32\\Wbem;%C:\\WINNT%\ \system32;%C:\\WINNT%;%C:\\WINNT%\\System32\\Wbem' >>> >>> os.putenv('PATH', 'C:\\WINNT\\system32') >>> >>> os.environ['PATH'] 'C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\System32\\Wbem;

RE: Pythonwin Install COM exceptions on Windows Vista Ultimate

2007-08-29 Thread Sandipan News
Here is the log at the end of the install: Copied pythoncom25.dll to C:\Outils\Python\pythoncom25.dll Copied pywintypes25.dll to C:\Outils\Python\pywintypes25.dll You do not have the permissions to install COM objects. The sample COM objects were not registered. -> Software\Python\PythonCore\2.5\H

RE: Pythonwin Install COM exceptions on Windows Vista Ultimate

2007-08-29 Thread Sandipan News
How do I deactivate UAC and Router? I did run as Administrator and installed both Python and Pythonwin into c:\Python25\ This is the error I got ... Here is the log at the end of the install: Copied pythoncom25.dll to C:\Outils\Python\pythoncom25.dll Copied pywintypes25.dll to C:\Outils\Python\

Re: replacing xml elements with other elements using lxml

2007-08-29 Thread Ultrus
Ah! I figured it out. I forgot that the tree is treated like a list. The solution was to replace the element with the first child, then use Python's insert(i,x) function to insert elements after the first one. lxml rocks! -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use os.putenv() ?

2007-08-29 Thread Graham Dumpleton
On Aug 30, 11:21 am, [EMAIL PROTECTED] wrote: > >>> import os > > >>> os.environ['PATH'] > > 'C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\System32\\Wbem;%C:\\WINNT%\ > \system32;%C:\\WINNT%;%C:\\WINNT%\\System32\\Wbem' > > >>> os.putenv('PATH', 'C:\\WINNT\\system32') > > >>> os.environ['PATH'] > > 'C:

RE: How to use os.putenv() ?

2007-08-29 Thread Ryan Ginstrom
> On Behalf Of [EMAIL PROTECTED] > What am I doing wrong? How do I change the value of an > environment variable? You'll have to go through the Windows registry. Please have a look at the following recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/55993 I also have my own routines

Re: IDE for Python

2007-08-29 Thread Eric S. Johansson
Ben Finney wrote: > Stefan Behnel <[EMAIL PROTECTED]> writes: > "Neither"? Emacs is both editor *and* IDE. I think of it more as feature full but somehow unsatisfying. For example, for those of us PRDs ( Politely Referred to as Disabled) who are trying to program by voice could use an enumerat

Re: Is LOAD_GLOBAL really that slow?

2007-08-29 Thread Carsten Haese
On Wed, 2007-08-29 at 19:23 -0600, Adam Olsen wrote: > It seems a common opinion that global access is much slower than local > variable access. However, my benchmarks show a relatively small > difference: > > ./python -m timeit -r 10 -v -s 'x = [None] * 1 > def foo(): > for i in x: > l

Re: status of Programming by Contract (PEP 316)?

2007-08-29 Thread Michele Simionato
On Aug 30, 1:17 am, Dan Stromberg - Datallegro <[EMAIL PROTECTED]> wrote: > IMO, putting Programming by Contract into python as part of the language > itself, or as a simple module, is a little bit like a company or > department coming up with a mission statement. It's easy to say that it's > mean

Re: Jython 2.2 on Ubuntu

2007-08-29 Thread smalltalk
On Aug 29, 10:50 pm, Neil Wallace <[EMAIL PROTECTED]> wrote: > Thanks Tim, > > I subscribed to the Jython group hosted by sourceforge, and they are a > great bunch of guys/gals. > > Here's what I did to fix my problem. > > 1. removed Jython 2.1 (using Synaptic)jytho > 2. added the following lines (

Re: Python molecular viewer

2007-08-29 Thread Greg Couch
Andy Cheesman <[EMAIL PROTECTED]> writes: >Dear People, >I was wondering if people could recommend a simple molecular viewing >package written in python. I'm working in Theoretical chemistry and I'm >not after an all-singing dancing molecular rendering package(pymol does >that rather well) but a

Re: self extracting zipefile (windows) and (standard module) zipefile

2007-08-29 Thread Scott David Daniels
Grant Edwards wrote: ... > Another option is to search through the file from the beginning > looking for whatever signature matches the beginning of a > "normal" zip file. The self-extracting zipfiles that I've > dissected are just an executable image concatenated with a > "normal" zipfile. If yo

Re: Python molecular viewer

2007-08-29 Thread Scott David Daniels
Andy Cheesman wrote: > Dear People, > > I was wondering if people could recommend a simple molecular viewing > package written in python. I'm working in Theoretical chemistry and I'm > not after an all-singing dancing molecular rendering package(pymol does > that rather well) but a program which r

We need PIGs :)

2007-08-29 Thread Martin Marcher
Hello, having worked quite a bit with python in the last months (some Java before, and some C++ before that) I was very impressed by an idea the Java people had. Explanation: the JSRs define how to implement certain services and or features in Java so that they can be reused. I haven't found such

Re: status of Programming by Contract (PEP 316)?

2007-08-29 Thread Russ
> I disagree. IMO automatic testing is thousands of times better than > design by contract and Python has already all the support you need > (unittest, doctest, py.test, nose, ...) In theory, anything you can verify with "design by contract" you can also verify with unittest and the rest. However

Re: self extracting zipefile (windows) and (standard module) zipefile

2007-08-29 Thread Werner
On 29 Aug., 15:23, [EMAIL PROTECTED] wrote: > On Aug 29, 6:53 am, Werner <[EMAIL PROTECTED]> wrote: > > > > > > > Hi, > > > I try to read (and extract) some "self extracting" zipefiles on a > > Windows system. The standard module zipefile seems not to be able to > > handle this. > > > >>> fName = r

Re: self extracting zipefile (windows) and (standard module) zipefile

2007-08-29 Thread Werner
On 30 Aug., 06:26, Scott David Daniels <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: > > ... > > > Another option is to search through the file from the beginning > > looking for whatever signature matches the beginning of a > > "normal" zip file. The self-extracting zipfiles that I've > > dis

list index()

2007-08-29 Thread zzbbaadd
What's with the index() function of lists throwing an exception on not found? Let's hope this is rectified in Python 3. If nothing else, add a function that doesn't throw an exception. There are a million situations where you can have an item not be in a list and it is not an exception situation.

<    1   2