Backwards Compatibility of Python versions
Joshua Macy
l0819m0v0smfm001 at sneakemail.com
Sun Feb 3 00:55:38 EST 2002
Paul Rubin wrote:
>
> I just tried that and it throws an error:
>
> $ python
> Python 1.5.2 (#1, Mar 3 2001, 01:35:43) [GCC 2.96 20000731 (Red Hat Linux 7.1 2 on linux-i386
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> from __future__ import division
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> ImportError: No module named __future__
> >>>
>
> That's with the version of Python currently being shipped with Red Hat
> Linux, so any scripts I distribute with that future import will crash
> for a lot of people.
>
try:
from __future__ import division
except ImportError:
pass
Of course, the semantics of division will then vary depending upon
whether the type is integer...but that's the problem that future
division is trying to solve, so I don't see any way around that.
Joshua
More information about the Python-list
mailing list