[Python-ideas] Smoothing transition to Python 3

Ben Finney ben+python at benfinney.id.au
Wed Jun 8 04:04:39 EDT 2016


Pavol Lisy <pavol.lisy at gmail.com> writes:

> do you have some drafts how to write (new) code supporting python from
> 2.4 - 2.7 with intention to port it to python3 in future?

I would advise:

* Write the code targeting Python 3.5 primarily.

* Back-port the code from the Python 3 source to Python 2.

This is a much easier transition because, instead of hunting
hard-to-find mistakes (e.g. the broken “text and bytes are the same”
assumption in Python 2 code), instead it entails adding some temporary
work-arounds. If the code works on Python 2 with your unit tests, your
job is done.

-- 
 \                “I got fired from my job the other day. They said my |
  `\          personality was weird. … That's okay, I have four more.” |
_o__)                                       —Bug-Eyed Earl, _Red Meat_ |
Ben Finney



More information about the Python-ideas mailing list