Python code for 2.5 and 2.4?
Mike Driscoll
kyosohma at gmail.com
Mon Feb 25 15:47:59 EST 2008
On Feb 25, 2:40 pm, Joseph Turian <tur... at gmail.com> wrote:
> I was given code that was written for python 2.5, and uses simple
> functions like 'all' which are not present in 2.4
>
> I want to make the code 2.4 compatible. What is the best way to do
> this?
> If I define function 'all', then won't I break 2.5 compatability?
>
> Thanks,
> Joseph
See http://docs.python.org/lib/built-in-funcs.html which shows the
current built-ins for Python. It also shows an equivalent function for
all() that should work in 2.4.
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>
HTH
Mike
More information about the Python-list
mailing list