What is your experience porting Python 2.7.x scripts to Python 3.x?

dieter dieter at handshake.de
Wed Jan 23 02:08:41 EST 2019


"Schachner, Joseph" <Joseph.Schachner at Teledyne.com> writes:
> ...
> For anyone who has moved a substantial bunch of Python 2 to Python 3,   can you please reply with your experience?

It can be simple and it can be difficult.

I have found "http://python-future.org/compatible_idioms.html"
especially useful.

> Did you run into any issues?

Besides the already mentioned "urllib*" and "bytes/str" problems,
I have had significant issues with "dict" (missing "iter*" methods, missing
"has_key").
Another important problem domain are doctests with unicode results.

>  Did 2to3 do its job well

I have not used "2to3" -- because I doubt, that it can handle
important cases, i.e. when a Python 2 "str" must become a Python 3 bytes
or when a "dict.{keys, values, items}" must be listified.




More information about the Python-list mailing list