[Python-ideas] Smoothing transition to Python 3

Giampaolo Rodola' g.rodola at gmail.com
Fri Jun 3 20:13:07 EDT 2016


On Fri, Jun 3, 2016 at 3:17 PM, Neil Schemenauer <
nas-pythonideas at arctrix.com> wrote:

> I'm nearly finished porting a decently size application from Python
> 2 to Python 3.  It has been a lot of work.  I am dubious as to
> whether the port was really the best use of time.  I can imagine
> there is still millions, possibly billions of lines of Python 2 code
> that has not yet been converted.  Further, my guess is the lines of
> Python 2 code are still growing faster than the lines of Python 3
> compatible code.  IMHO, we need to do better in making it easier for
> people to port code.
>
> Here is a thought that occured to me.  Create a patched version of
> Python 3.x, making a stepping stone version for people porting from
> Python 2.  I know this would have been useful for me.  Specific
> changes that would be helpful, all generating warnings so code can
> be eventually fixed:
>
> - comparision with None, smaller than all other types
>
> - comparision of distinct types: use Python 2 behavior (i.e. order
>   by type name)
>
> - mixing of unicode strings with byte strings: decode/encode
>   using latin-1
>

To me this sounds more like going back to Python 2 rather than facilitating
the transition, especially #3.
Unfortunately there's no middle ground in there: it's either "do this or
that" and that's why it's so painful.
Incidentally, all these things you mentioned are bad practices which may
hide bugs you may not even be aware of.
The more I think about the porting subject, the more I realize that the
difficulty mainly resides in how good your Python 2 code base is. Python 3
attempted to be a better language (mainly) by becoming stricter. As such, a
badly written Python 2 code base is harder to port because Python 3 stands
in your way acting as a referee for all the mistakes you've made in the
past, forcing you to fix them all at once. That's its biggest advantage and
damnation at the same time.


-- 
Giampaolo - http://grodola.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160604/6faf7f7a/attachment.html>


More information about the Python-ideas mailing list