[Python-ideas] from __past__ import division, str, etc

Alejandro López Correa alc at spika.net
Wed Jan 8 15:57:07 CET 2014


Hi,

I'm new here. I am sorry if this idea has already been discussed, but I
have not found a way to search this list (I am not used to mailing lists at
all).

I've seen recently some discussion in reddit about python 2 vs python 3,
and the slow adoption of the latter. I am proposing here pragmatic way to
speed up the process of porting old code and thus solving the split in the
community, that I believe it is a serious threat. It is not clean, not at
all, but it might work: just give python 2 whiners what they [we] want, and
do it using "from __past__ import", in a similar way "from __future__
import" is used.

The advantage of this method is that porting old code would be trivial, and
each module could be rewritten at its own pace (for example, when a new
feature is required).

The 2to3.py tool could be updated to perform as many safe changes as it
could (safe in the sense of 100% certainty of not breaking anything), and
import old features as needed. I am thinking both in language syntax like
division behaviour, unicode, str, etc, and major library changes. Past
features may be added per request, and the 2to3 tool should allow users to
force the use of any of them, just in case. The whole process should be
almost automatic: the user might just run the tool at the root folder of
the code base, with any required command-line arguments to force some
features, and the tool would generate working python3 code.

There might be some issues regarding the interaction of new python3 code
with code that uses old features, maintaining a more complex code base, and
there might be other issues I am missing (like fundamental changes in
python 3 internal architecture that can't accomodate some older features),
but it might work and I think it could be useful to discuss this idea.

A potential non technical problem involves users abusing this mechanism to
write new code with old features, but I believe it is a minor risk if this
means the whole python community finally moves to python 3.

Hope this is useful.

Alejandro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140108/2b119093/attachment.html>


More information about the Python-ideas mailing list