making python 2.3 not complain about generator expressions?

Andrew Koenig ark at acm.org
Tue Jul 13 05:40:07 CEST 2004


"Dan Christensen" <jdc at uwo.ca> wrote in message
news:87iscs4m06.fsf at uwo.ca...
> 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.

How about

    if pythonversion >= 2.4:
        import newcode as code
    else:
        import oldcode as code





More information about the Python-list mailing list