making python 2.3 not complain about generator expressions?
Dan Christensen
jdc at uwo.ca
Mon Jul 12 23:35:53 EDT 2004
I'd like to be able to do something like:
if pythonversion >= 2.4:
g = (x for x in [1,2,3])
else:
g = iter([1,2,3])
But even though the first branch doesn't execute in python 2.3, the
parser still complains.
I can think of some tricks using strings and eval. Is there anything
more elegant?
(By the way, what's the canonical way for a script to find out which
version of python it is running in?)
Dan
More information about the Python-list
mailing list