PEP0238 lament

piet at cs.uu.nl piet at cs.uu.nl
Fri Jul 27 04:13:30 EDT 2001


>>>>> david at boddie.net (David Boddie) (DB) writes:

DB> So, if you're already resigned to that then just changing __future__
DB> to something else like

DB> from __behaviour__ import float_division

DB> would be just as easy, and wouldn't break existing code. <wink>

This just won't work. The most important reason for the change in division
is that people are caught by the integer division by surprise. So anything
special that they have to do to get float division will not help. That's
also the reason that it won't help to introduce // for the new behaviour
and leave / for the old behaviour.

I have an idea that might help the transition to become less painful:
Like someone else noticed about the transition in LaTeX from 2.09 to 2e
(\documentstyle vs. \documentclass):
If python files for the 3.0 version and beyond could be recognized then at
least old files will not be silently executed with the wrong semantics.

So we could require that in Python 3+ python files have to start with:
module name

This doesn't even require module to be a keyword. name should be the same
name to import the file (i.e. the filename).

>From Python 3.0 onwards files without a module statement should no longer
be accepted. These must be repaired, i.e. checked for integer divisions and
a module statement added. So they can no longer silently break.

In the transition period both forms should be acceptable with the old form
finally producing warnings.

The module declaration could also be given parameters to specify a specific
behaviour, e.g. it could specify that this module wants the old integer
division:

module mymod (int_div).

-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Python-list mailing list