Emulate @classmethod using decorator and descriptor
Hello, I was recently learning python decorator and descriptor and emulated a @classmethod decorator: class EmuClassMethod(object): def __init__(self, f=None): self.f = f def __get__(self, obj, klass=None): if klass is None: klass = type(obj) def wrapped(*args): return self.f(klass, *args) return wrapped class Test(object): @EmuClassMethod def t(cls): print "I'm %s" % cls.__name__ It worked, and seems that a function decorator works as follows: # decf is a decorator @decf def func(): print 'func' will be "converted" to: def func(): print 'func' func = decf(func) Is this really the case? Or correct me if i'm wrong. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does Python never add itself to the Windows path?
Ben Sizer wrote: > I've installed several different versions of Python across several > different versions of MS Windows, and not a single time was the Python > directory or the Scripts subdirectory added to the PATH environment > variable. Every time, I've had to go through and add this by hand, to > have something resembling a usable Python installation. No such > problems on Linux, whether it be Mandrake/Mandriva, Fedora Core, or > Kubuntu. So why is the Windows install half-crippled by default? I just > rediscovered this today when trying to run one of the Turbogears > scripts, but this has puzzled me for years now. > Well, after Python is installed on a Windows platform, files with extention ".py" or ".pyw" are automatically associated with python or pythonw. If a python script is double-clicked or input something like "sth.py" in the "cmd" box, the python interpreter is automatically called. I don't see any proplem or inconvenience with this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Noobie: Open file -> read characters & multiply
gonzlobo wrote:
> I've been using Python for a few days. It's such the perfect language
> for parsing data!
>
> I really like it so far, but I'm having a hard time reading a file,
> reading the first few hex characters & converting them to an integer.
> Once the characters are converted to an integer, I'd like to write the
> data to another file.
>
> Here's the code snipped to the bare minimum:
> ---
> # Open File
> AP_File= open("AP.txt", "r")
> decoded_File= open("decoded.txt", "w")
>
> # read & process data line by line
> for line in AP_File:
>time = int(hex(line[0:8]), 16) * 0.0001 # this line is completely
> hosed!
>decodedFile.write(time)
>
> #close files
> AP_File.close()
> decoded_File.close()
> ---
> AP.txt
> 00d5 26 0600 80 00 ec 80 02 03 7d db 02 33
> 00d5 26 0601 80 00 80 00 02 37 fe 54 01 09
> 00d5 06 0602 80 00 e0 00 01 29 fe d2 69 99
> 00d5 06 0603 80 00 e0 00 02 29 fe d2 6a 99
> 00d5 26 0604 80 00 fe 54 02 09 80 00 01 5d
> 00d5 06 0605 80 00 e0 00 02 15 fc 71 ca 0b
> 00d5 4a 0610 81 00 86 00 02 26 12 00 02 a6
> 00d5 4f 0611 00 00 00 50 00 00 00 00 07 00
> 00d5 06 0612 80 00 e0 00 01 15 fc 71 c9 0b
> 00d5 0a 0613 08 5c 04 88 08 98 00 00 00 00
> 00d5 06 0614 80 00 e0 00 02 01 60 79 82 2b
> 00d5 0a 0615 08 00 00 00 00 00 00 00 00 00
> 00d5 26 0616 80 00 80 00 02 5d 04 22 3a 88
> (actual files are 250MB!)
>
> decodedTime.txt (should be)
> 0.0213 26 0600 80 00 ec 80 02 03 7d db 02 33
> ...
>
> My boss and I are trying to complete the same task (he figured out how
> to do it, but his code uses a while != "" loop and doesn't look
> pythony (it looks too 'c'). Not that there's anything wrong with that!
>
> Any help is really appreciated.
Use the built-in int(). It has an optional argument "radix" which
specifies the base for the conversion. For example:
>>> int("0x0A", 16)
>>> 10
--
http://mail.python.org/mailman/listinfo/python-list
Re: Noobie: Open file -> read characters & multiply
WaterWalk wrote:
> gonzlobo wrote:
> > I've been using Python for a few days. It's such the perfect language
> > for parsing data!
> >
> > I really like it so far, but I'm having a hard time reading a file,
> > reading the first few hex characters & converting them to an integer.
> > Once the characters are converted to an integer, I'd like to write the
> > data to another file.
> >
> > Here's the code snipped to the bare minimum:
> > ---
> > # Open File
> > AP_File= open("AP.txt", "r")
> > decoded_File= open("decoded.txt", "w")
> >
> > # read & process data line by line
> > for line in AP_File:
> >time = int(hex(line[0:8]), 16) * 0.0001 # this line is completely
> > hosed!
> >decodedFile.write(time)
> >
> > #close files
> > AP_File.close()
> > decoded_File.close()
> > ---
> > AP.txt
> > 00d5 26 0600 80 00 ec 80 02 03 7d db 02 33
> > 00d5 26 0601 80 00 80 00 02 37 fe 54 01 09
> > 00d5 06 0602 80 00 e0 00 01 29 fe d2 69 99
> > 00d5 06 0603 80 00 e0 00 02 29 fe d2 6a 99
> > 00d5 26 0604 80 00 fe 54 02 09 80 00 01 5d
> > 00d5 06 0605 80 00 e0 00 02 15 fc 71 ca 0b
> > 00d5 4a 0610 81 00 86 00 02 26 12 00 02 a6
> > 00d5 4f 0611 00 00 00 50 00 00 00 00 07 00
> > 00d5 06 0612 80 00 e0 00 01 15 fc 71 c9 0b
> > 00d5 0a 0613 08 5c 04 88 08 98 00 00 00 00
> > 00d5 06 0614 80 00 e0 00 02 01 60 79 82 2b
> > 00d5 0a 0615 08 00 00 00 00 00 00 00 00 00
> > 00d5 26 0616 80 00 80 00 02 5d 04 22 3a 88
> > (actual files are 250MB!)
> >
> > decodedTime.txt (should be)
> > 0.0213 26 0600 80 00 ec 80 02 03 7d db 02 33
> > ...
> >
> > My boss and I are trying to complete the same task (he figured out how
> > to do it, but his code uses a while != "" loop and doesn't look
> > pythony (it looks too 'c'). Not that there's anything wrong with that!
> >
> > Any help is really appreciated.
>
> Use the built-in int(). It has an optional argument "radix" which
> specifies the base for the conversion. For example:
> >>> int("0x0A", 16)
> >>> 10
Oh I forget that ">>>" will cause the line to be hidden by default. The
example is:
int("0x0A", 16)# will return 10
--
http://mail.python.org/mailman/listinfo/python-list
Re: Noobie: Open file -> read characters & multiply
WaterWalk wrote:
> WaterWalk wrote:
> > gonzlobo wrote:
> > > I've been using Python for a few days. It's such the perfect language
> > > for parsing data!
> > >
> > > I really like it so far, but I'm having a hard time reading a file,
> > > reading the first few hex characters & converting them to an integer.
> > > Once the characters are converted to an integer, I'd like to write the
> > > data to another file.
> > >
> > > Here's the code snipped to the bare minimum:
> > > ---
> > > # Open File
> > > AP_File= open("AP.txt", "r")
> > > decoded_File= open("decoded.txt", "w")
> > >
> > > # read & process data line by line
> > > for line in AP_File:
> > >time = int(hex(line[0:8]), 16) * 0.0001 # this line is completely
> > > hosed!
> > >decodedFile.write(time)
> > >
> > > #close files
> > > AP_File.close()
> > > decoded_File.close()
> > > ---
> > > AP.txt
> > > 00d5 26 0600 80 00 ec 80 02 03 7d db 02 33
> > > 00d5 26 0601 80 00 80 00 02 37 fe 54 01 09
> > > 00d5 06 0602 80 00 e0 00 01 29 fe d2 69 99
> > > 00d5 06 0603 80 00 e0 00 02 29 fe d2 6a 99
> > > 00d5 26 0604 80 00 fe 54 02 09 80 00 01 5d
> > > 00d5 06 0605 80 00 e0 00 02 15 fc 71 ca 0b
> > > 00d5 4a 0610 81 00 86 00 02 26 12 00 02 a6
> > > 00d5 4f 0611 00 00 00 50 00 00 00 00 07 00
> > > 00d5 06 0612 80 00 e0 00 01 15 fc 71 c9 0b
> > > 00d5 0a 0613 08 5c 04 88 08 98 00 00 00 00
> > > 00d5 06 0614 80 00 e0 00 02 01 60 79 82 2b
> > > 00d5 0a 0615 08 00 00 00 00 00 00 00 00 00
> > > 00d5 26 0616 80 00 80 00 02 5d 04 22 3a 88
> > > (actual files are 250MB!)
> > >
> > > decodedTime.txt (should be)
> > > 0.0213 26 0600 80 00 ec 80 02 03 7d db 02 33
> > > ...
> > >
> > > My boss and I are trying to complete the same task (he figured out how
> > > to do it, but his code uses a while != "" loop and doesn't look
> > > pythony (it looks too 'c'). Not that there's anything wrong with that!
> > >
> > > Any help is really appreciated.
> >
> > Use the built-in int(). It has an optional argument "radix" which
> > specifies the base for the conversion. For example:
> > >>> int("0x0A", 16)
> > >>> 10
>
> Oh I forget that ">>>" will cause the line to be hidden by default. The
> example is:
> int("0x0A", 16)# will return 10
I misunderstand the question, sorry for this.
Why not just split the line read since each number is separated by
space or tab. After splitting there is a list of numbers, then convert
the first element and write the list into a file.
--
http://mail.python.org/mailman/listinfo/python-list
Re: I'm having trouble understanding scope of a variable in a subclass
Pyenos wrote: > Approach 1: > > class Class1: > class Class2: > def __init__(self):self.variable="variable" > > class Class3: > def method():print Class1().Class2().variable #problem > > Approach 1.1: > > class Class1: > class Class2: > def __init__(self):self.variable="variable" > > class Class3: > def method():print Class1.Class2.variable #problem > Approach 2: > > class Class1: > class Class2: > variable="variable" > > class Class3: > def method():print Class1().Class2().variable #problem > Approach 2.1: > > class Class1: > class Class2: > variable="variable" > > class Class3: > def method():print Class1.Class2.variable #problem > > Is there a correct solution in the above? Or, what is the solution? Your definition of Class3.method() shall have a 'self' argument, then the above will all be ok. -- http://mail.python.org/mailman/listinfo/python-list
Python's "only one way to do it" philosophy isn't good?
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a footprint which says: "Indeed, one often hears arguments against building exibility into an engineered sys- tem. For example, in the philosophy of the computer language Python it is claimed: \There should be one|and preferably only one|obvious way to do it."[25] Science does not usually proceed this way: In classical mechanics, for example, one can construct equa- tions of motion using Newtonian vectoral mechanics, or using a Lagrangian or Hamiltonian variational formulation.[30] In the cases where all three approaches are applicable they are equivalent, but each has its advantages in particular contexts." I'm not sure how reasonable this statement is and personally I like Python's simplicity, power and elegance. So I put it here and hope to see some inspiring comments. -- http://mail.python.org/mailman/listinfo/python-list
Make Tkinter canvas respond to MouseWheel event
Hello. When I tried to make Tkinter canvas widget respond to
MouseWheel event on Windows XP, I failed. The canvas just doesn't
receive MouseWheel event. I used bind_all to find out which widget
receives this event and the result showed that only the top Tk widget
gets it. This is really annoying. I wonder if this problem exists on
other platform. I googled, but found no appliable solution, so I wrote
one as following. It's not perfect, but works well for me. Please
comment on my implementation, and if you have better solution, please
show it.
In this implementation, I bind the MouseWheel to the toplevel window
which contains the canvas.
To test if the canvas shall scroll, I check if the coordinates of the
mouse is within the canvas.
from Tkinter import *
class ScrolledCanvas(Canvas):
def __init__(self, parent, xscroll=False, yscroll=False, *args,
**kargs):
frm = Frame(parent)
frm1 = Frame(frm)
Canvas.__init__(self, frm1, *args, **kargs)
self.pack(side=LEFT, fill=BOTH, expand=YES)
frm1.pack(side=TOP, fill=BOTH, expand=YES)
frm2 = Frame(frm)
frm2.pack(side=BOTTOM, expand=YES, fill=X)
if xscroll:
xsbar = Scrollbar(frm2)
xsbar.config(orient=HORIZONTAL)
xsbar.config(command=self.xview)
self.config(xscrollcommand=xsbar.set)
xsbar.pack(fill=BOTH, expand=YES)
self.winfo_toplevel().bind('',
self.onMouseWheelX)
if yscroll:
ysbar = Scrollbar(frm1)
ysbar.config(orient=VERTICAL)
ysbar.config(command=self.yview)
self.config(yscrollcommand=ysbar.set)
ysbar.pack(side=RIGHT, fill=BOTH, expand=YES)
self.winfo_toplevel().bind('',
self.onMouseWheelY)
self.pack = frm.pack # because the canvas is not contained in
a frame
self.canvasFrame = frm
def onMouseWheelY(self, event):
if event.widget == self.winfo_toplevel() and \
self.bInCanvas(event.x, event.y):
self.yview_scroll(-event.delta, UNITS)
def onMouseWheelX(self, event):
if event.widget == self.winfo_toplevel() and \
self.bInCanvas(event.x, event.y):
self.xview_scroll(-event.delta, UNITS)
def bInCanvas(self, x, y):
if x > self.canvasFrame.winfo_x() and \
y > self.canvasFrame.winfo_y() and \
x < self.canvasFrame.winfo_x() + int(self.winfo_width())
and \
y < self.canvasFrame.winfo_y() + int(self.winfo_height()):
return True
return False
def test():
top = Frame()
top.pack(expand=YES, fill=BOTH)
sc = ScrolledCanvas(top, xscroll=True, yscroll=True, bg='Brown',
relief=SUNKEN)
sc.config(scrollregion=(0,0,1000, 1000))
sc.config(yscrollincrement=1)
sc.config(xscrollincrement=1)
sc.pack()
for i in range(10):
sc.create_text(150, 50+(i*100), text='spam'+str(i),
fill='beige')
top.mainloop()
if __name__ == '__main__':
test()
--
http://mail.python.org/mailman/listinfo/python-list
About reading Python code
Hello. I wonder what's the effective way of figuring out how a piece of python code works. With C I often find it very useful to be able to run the code in step mode and set breakpoints in a debugger so I can watch how the it executes, how the data change and how the code jumps from one function to another. But with Python, the debugger is a little primitive. The default IDLE doesn't even allow me to set a breakpoint. When the code is long, I am often lost in it. So I'm curious how to read code effectively. I agree that python code is clear, but when it becomes long, reading it can still be a hard work. -- http://mail.python.org/mailman/listinfo/python-list
Re: About reading Python code
On Mar 17, 11:54 am, WaterWalk <[EMAIL PROTECTED]> wrote: > Hello. I wonder what's the effective way of figuring out how a piece > of python code works. With C I often find it very useful to be able to > run the code in step mode and set breakpoints in a debugger so I can > watch how the it executes, how the data change and how the code jumps > from one function to another. But with Python, the debugger is a > little primitive. The default IDLE doesn't even allow me to set a > breakpoint. When the code is long, I am often lost in it. > > So I'm curious how to read code effectively. I agree that python code > is clear, but when it becomes long, reading it can still be a hard > work. BTW. I think this problem also exists in other script languages. -- http://mail.python.org/mailman/listinfo/python-list
Re: About reading Python code
On Mar 17, 1:54 pm, Stargaming <[EMAIL PROTECTED]> wrote: > On Sun, 16 Mar 2008 20:54:01 -0700, WaterWalk wrote: > > Hello. I wonder what's the effective way of figuring out how a piece of > > python code works. > > If your Python code is well-written, it should be easy figuring out what > it means by just reading it. For more complex programs, of course, this > method can fail. > > > With C I often find it very useful to be able to run > > the code in step mode and set breakpoints in a debugger so I can watch > > how the it executes, how the data change and how the code jumps from one > > function to another. But with Python, the debugger is a little > > primitive. The default IDLE doesn't even allow me to set a breakpoint. > > When the code is long, I am often lost in it. > > IDLE is just, well, a batteries-included editor. There are many people > (me included) who do *not* like it because it's so weak and doesn't have > any real uses cases if your programs get sufficiently complex (because > IDLE itself is sufficiently primitive). > > You might be interested in *real* debuggers, such as the Python Debugger > `PDB <http://docs.python.org/lib/module-pdb.html>`_. If you don't find > its usage obvious, a quick google search just turned up a nice `tutorial > <http://www.ferg.org/papers/debugging_in_python.html>`_. > > You might find the `Python Profilers <http://docs.python.org/lib/ > profile.html>`_ particularly interesting, `profile` for finding out which > function sucks up the most calls/time, `trace` for more sophisticated > stuff. > `pythontracer <http://code.google.com/p/pythontracer/>` sounds like a > good combination of both. > > > So I'm curious how to read code effectively. I agree that python code is > > clear, but when it becomes long, reading it can still be a hard work. > > A common practice is just inserting `print` statements since it's so > easy. If you think your debugging isn't temporary but could be useful and > will be enabled every now and then, you could also use the `logging > module <http://docs.python.org/lib/module-logging.html>`_ with the > ``DEBUG`` level. > > There was a blog post recently about how to do this `generically for > functions <http://wordaligned.org/articles/echo>`_. > > > BTW. I think this problem also exists in other script languages. > > FWIW, I think it's particularly easier in scripting languages to > implement all kinds of tracing (apart from debugging, which is rather > unpopular in Python) because you have one *extra* level (the interpreter) > between your machine and your code. > > HTH, > Stargaming Thanks for your informative reply. I'll try them. I think I need more practice to familiarize myself with those idioms of Python. -- http://mail.python.org/mailman/listinfo/python-list
About print exception message
Until Python 2.5, the exception object still uses ansi string. Thus, in the following example: f = open(u"\u6d4b.log") Suppose the file to open does not exist, the output message of the exception maybe like: [Errno 2] No such file or directory: u'\u6d4b.log' This is not a clear message. I finally work out a rough solution. Since the unicode string in the exception message is always in the form of "\u" or maybe "\U", it's possible to manual convert those unicode escape sequence into the "real" unicode character. The following is the code: import StringIO import locale STATE_NORMAL = 0 STATE_BACK_SLASH = 1 STATE_LOWER_U = 2 STATE_UPPER_U = 3 def ansiu2u(s, enc): '"convert '\u' or '\U' sequences in a non-unicode string to their coresponding unicode characters''' i = 0 state = STATE_NORMAL s = unicode(s, enc) result = StringIO.StringIO() while i < len(s): c = s[i] if state == STATE_NORMAL: if c == u'\\': state = STATE_BACK_SLASH else: result.write(c) i += 1 elif state == STATE_BACK_SLASH: if c == u'u': state = STATE_LOWER_U elif c == u'U': state = STATE_UPPER_U else: state = STATE_NORMAL result.write(u'\\') result.write(c) i += 1 elif state == STATE_LOWER_U: unic = int(s[i : i + 4], 16) unic = unichr(unic) result.write(unic) i += 4 state = STATE_NORMAL elif state == STATE_UPPER_U: unic = int(s[i : i + 8], 16) unic = unichr(unic) result.write(unic) i += 8 state = STATE_NORMAL r = result.getvalue() result.close() return r def obj2unicode(obj): s = str(obj) return ansiu2u(s, locale.getdefaultlocale()) Using this function, when printing exceptions, the result will always be in "good" forms. Any comments? -- http://mail.python.org/mailman/listinfo/python-list
Re: About print exception message
On Oct 9, 9:46 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Thu, 9 Oct 2008 06:37:04 -0700 (PDT), WaterWalk <[EMAIL PROTECTED]> wrote:
> >Until Python 2.5, the exception object still uses ansi string. Thus,
> >in the following example:
>
> >f = open(u"\u6d4b.log")
>
> >Suppose the file to open does not exist, the output message of the
> >exception maybe like:
> >[Errno 2] No such file or directory: u'\u6d4b.log'
>
> >This is not a clear message.
>
> I disagree. But if you'd rather see the character (or a replacement
> character,
> or possibly an empty box, depending on your environment's text rendering
> capabilities), it's a bit easier than writing that big function:
>
> >>> try: open(u'\N{WHITE SMILING FACE}')
>
> ... except IOError, e: print str(e).decode('unicode-escape')
> ...
> [Errno 2] No such file or directory: u'☺'
>
Yes, this is a more concise solution. Thank you.
--
http://mail.python.org/mailman/listinfo/python-list
Name lookup inside class definition
Hello. Consider the following two examples: class Test1(object): att1 = 1 def func(self): print Test1.att1// ok class Test2(object): att1 = 1 att2 = Test2.att1 // NameError: Name Test2 is not defined It seems a little strange. Why a class name can be used in a method while cannot be used in the class block itself? I read the "Python Reference Manual"(4.1 Naming and binding ), but didn't get a clue. -- http://mail.python.org/mailman/listinfo/python-list
Re: Name lookup inside class definition
Ah, I see. Thank you all. -- http://mail.python.org/mailman/listinfo/python-list
unicode in exception traceback
Hello. I just found on Windows when an exception is raised and traceback info is printed on STDERR, all the characters printed are just plain ASCII. Take the unicode character u'\u4e00' for example. If I write: print u'\u4e00' If the system locale is "PRC China", then this statement will print this character as a single Chinese character. But if i write: assert u'\u4e00' == 1 An AssertionError will be raised and traceback info will be put to STDERR, while this time, u'\u4e00' will simply be printed just as u'\u4e00', several ASCII characters instead of one single Chinese character. I use the coding directive commen(# -*- coding: utf-8 -*-)t on the first line of Python source file and also save it in utf-8 format, but the problem remains. What's worse, if i directly write Chinese characters in a unicode string, when the traceback info is printed, they'll appear in a non- readable way, that is, they show themselves as something else. It's like printing something DBCS characters when the locale is incorrect. I think this problem isn't unique. When using some other East-Asia characters, the same problem may recur. Is there any workaround to it? -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode in exception traceback
On Apr 3, 5:56 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > WaterWalk wrote: > > Hello. I just found on Windows when an exception is raised and > > traceback info is printed on STDERR, all the characters printed are > > just plain ASCII. Take the unicode character u'\u4e00' for example. If > > I write: > > > print u'\u4e00' > > > If the system locale is "PRC China", then this statement will print > > this character as a single Chinese character. > > > But if i write: assert u'\u4e00' == 1 > > > An AssertionError will be raised and traceback info will be put to > > STDERR, while this time, u'\u4e00' will simply be printed just as > > u'\u4e00', several ASCII characters instead of one single Chinese > > character. I use the coding directive commen(# -*- coding: utf-8 -*-)t > > on the first line of Python source file and also save it in utf-8 > > format, but the problem remains. > > > What's worse, if i directly write Chinese characters in a unicode > > string, when the traceback info is printed, they'll appear in a non- > > readable way, that is, they show themselves as something else. It's > > like printing something DBCS characters when the locale is incorrect. > > > I think this problem isn't unique. When using some other East-Asia > > characters, the same problem may recur. > > > Is there any workaround to it? > > Pass a byte string but make some effort to use the right encoding: > > >>> assert False, u"\u4e00".encode(sys.stdout.encoding or "ascii", > >>> "xmlcharrefreplace") > > Traceback (most recent call last): > File "", line 1, in > AssertionError: 一 > > You might be able to do this in the except hook: > > $ cat unicode_exception_message.py > import sys > > def eh(etype, exc, tb, original_excepthook=sys.excepthook): > message = exc.args[0] > if isinstance(message, unicode): > exc.args = (message.encode(sys.stderr.encoding or "ascii", > "xmlcharrefreplace"),) + exc.args[1:] > return original_excepthook(etype, exc, tb) > > sys.excepthook = eh > > assert False, u"\u4e00" > > $ python unicode_exception_message.py > Traceback (most recent call last): > File "unicode_exception_message.py", line 11, in > assert False, u"\u4e00" > AssertionError: 一 > > If python cannot figure out the encoding this falls back to ascii with > xml charrefs: > > $ python unicode_exception_message.py 2>tmp.txt > $ cat tmp.txt > Traceback (most recent call last): > File "unicode_exception_message.py", line 11, in > assert False, u"\u4e00" > AssertionError: 一 > > Note that I've not done any tests; e.g. if there are exceptions with > immutable .args the except hook itself will fail. > > Peter Thanks. My brief test indicates that it works. I'll try it in more situations. -- http://mail.python.org/mailman/listinfo/python-list
