Re: unicode() vs. s.decode()

2009-08-05 Thread 1x7y2z9
unicode() has LOAD_GLOBAL which s.decode() does not. Is it generally the case that LOAD_ATTR is slower than LOAD_GLOBAL that lead to your intuition that the former would probably be slower? Or some other intuition? Of course, the results from timeit are a different thing - I ask about the

boolean OR gotcha

2009-08-04 Thread 1x7y2z9
0 or None is None True None or 0 is None False None or 0 is 0 True Yes, this is explained in the docs: The expression x or y first evaluates x; if x is true, its value is returned; otherwise, y is evaluated and the resulting value is returned. Another one (also explainable): 0 or None ==

Re: boolean OR gotcha

2009-08-04 Thread 1x7y2z9
Did not intend that there was a problem. Just a gotcha or a fun little titbit ... maybe. :) On Aug 4, 1:25 pm, Jan Kaliszewski z...@chopin.edu.pl wrote: 04-08-2009 o 22:11:18 1x7y2z9 1x7y...@gmail.com wrote: Another one (also explainable): 0 or None == None or 0 True # Above is same

URLError errno and strerror not set

2009-07-16 Thread 1x7y2z9
python 2.5.2 errno, strerror and message do not appear to be set in the following two cases (at least). Is this to be expected? (as an aside, arg[0] is set) # case 1 print exception, exception.errno, exception.strerror, exception.message == '' urlopen error (111, 'Connection refused') None

Re: re.NONE

2009-06-23 Thread 1x7y2z9
On Jun 22, 5:56 pm, Lawrence D'Oliveiro l...@geek- central.gen.new_zealand wrote: In message e9213fb3- c77d-4a47-8cb4-7dd916d69...@s1g2000prd.googlegroups.com, 1x7y2z9 wrote: Not sure if this is defined in a later version, but it would be nice to define re.NONE = 0 in the re module. Do so

re.NONE

2009-06-22 Thread 1x7y2z9
I am currently using python v2.5.2. Not sure if this is defined in a later version, but it would be nice to define re.NONE = 0 in the re module. This would be useful in cases such as: flags = re.DOTALL if dotall else re.NONE Also useful for building up flags by ORing with other flags. Thanks.

decorating a method in multiple child classes

2008-07-17 Thread 1x7y2z9
Say, we have a (parent) class P. It has N child classes C1(P), C2(P) ... CN(P) Each of the child classes defines (differently) a method func(). I wish to decorate all of the CX.func() in the same way. One way to do this is to add a decorator to each of the derived classes. But this is tedious