[Python-ideas] Smoothing transition to Python 3

Neil Schemenauer nas-pythonideas at arctrix.com
Fri Jun 3 09:17:30 EDT 2016


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

- dict objects: make keys() items() values() return special sequence
  that warns if iterated over multiple times or indexed as sequence

Changes that are not necessary as porting code is easy:

- print function syntax

- try/except syntax

- standard module renaming

- __next__/next()

- long type, literal syntax

- true division as default



More information about the Python-ideas mailing list