Python code for 2.5 and 2.4?

Arnaud Delobelle arnodel at googlemail.com
Mon Feb 25 17:02:50 EST 2008


On Feb 25, 8:47 pm, Mike Driscoll <kyoso... at gmail.com> wrote:
>
> You can do a check at the beginning of your file by importing the sys
> module. Something like this:
>
> <code>
> # untested
> import sys
> version = sys.version.split(' ')[0]
>
> if '2.5' not in version:
>    # use custom all() script
>
> </code>

Or simply:

try:
    all
except NameError:
    def all(iterable):
        for x in iterable:
            if not x: return False
        return True

--
Arnaud




More information about the Python-list mailing list