4 ms·
It's easy to write code which runs on both Python 2 and 3 — there are tools like six which help maintain compatibility on the relocated standard library modules
by acdha 6y ago
It's easy to write code which runs on both Python 2 and 3 — there are tools like six which help maintain compatibility on the relocated standard library modules, and tools like futurize/modernize which will rewrite your code automatically:
https://python-future.org/compatible_idioms.html https://python-future.org/compatible_idioms.html
The biggest problem now is that an increasing number of libraries dropped Python 2 support after end-of-life and so you might find that trying to support 2 in your code is fine but you need to depend on older versions of outside libraries. Most of the remaining problems tend to be cases where someone was failing to handle Unicode correctly and is blaming the required cleanup on Python 3 exposing the existing shortcomings of their code. Those problems can be harder to resolve if you have a bunch of sloppy input/output points in a codebase without good test coverage.
- Aachen 6y agoAll the more reason to move to python 3 instead of staying on 2, hence my confusion how they still have parts running in python 2. Other replies clarified that this is about backwards compatibility, not updating code to run in python 3 at all.