Any gotchas in returning a subclass instance from __new__?

2006-08-01 Thread s . lipnevich
Hi All, Is anything wrong with the following code? class Superclass(object): def __new__(cls): # Questioning the statement below return super(Superclass, cls).__new__(Subclass) class Subclass(Superclass): pass if __name__ == '__main__': instance = Superclass() print instance It

GNU date input formats in Python

2006-07-04 Thread s . lipnevich
Hi All, I tried looking in several places, including Python's documentation, CheeseShop, general search, and didn't find anything. Is implementation of GNU date input formats (http://www.gnu.org/software/tar/manual/html_node/tar_109.html) available in Python? I'm primarily interested in parsing

Re: For loop and list comprehension similarity

2006-03-27 Thread s . lipnevich
I think I like generator comprehension in this case better than either list comprehension or a filter because both of the latter create a new full result list before the loop even begins. At least I suppose they do. Also, I think Mitja's suggestion if not test: continue and Terry's filter function

For loop and list comprehension similarity

2006-03-26 Thread s . lipnevich
Hi All, I apologize if this was brought up before, I couldn't find any prior art :-). On more than one occasion, I found myself wanting to use a conditional loop like this (with Invalid syntax error, of course): for i in c if test: print i*2 ...because it's similar to

Re: For loop and list comprehension similarity

2006-03-26 Thread s . lipnevich
Thank you for replying, Mitja! That *is* a nice alternative. Do you think it's a good idea to ask on comp.python.devel if they would be interested in a PEP about this (provided there is none)? Cheers, Sergey. -- http://mail.python.org/mailman/listinfo/python-list

Re: For loop and list comprehension similarity

2006-03-26 Thread s . lipnevich
Why not combine the two: I guess because (at least in source code) you're doing a loop twice :-). I don't know what a compiler would do. I think though that the for i in c if test: construct is more readable and maybe can even be better optimized. Thanks! Sergey. --