PEP0238 lament

Terry Reedy tjreedy at home.com
Tue Jul 24 17:42:45 CEST 2001


> I return to my question. Suppose Python 2.2 is released with this
> __future__ division. Now suppose I must maintain some code which can
> run on Python 2.0, 2.1 and 2.2, which needs integer division.

The answer [revised] I gave yesterday in 'Re: A way to accomodate
language changes':

[In general, do not use new meanings]

For the proposed division change, the 'new' meanings will be int/int
and float//float.  So write float(int)/int and floor(float/float)
instead.  Only write int//int or float/float.  With the tokenizer
module, it will then be easy to change all instances of int//int to
int/int (old meaning).  [Skip Montano already posted a program for the
other direction; changing it to go back is trivial.] It should even
even be possible to have
package installers check sys.version and do this conversion on site as
needed.  For newly written code, the harder problem will be to not use
any of the other neat new features [like iterators/generators], which
mostly *cannot* be
automatically back converted.







More information about the Python-list mailing list