5 ms·
It's quite possible that someone will come up with a good enough automatic 2->3 converter which alleviate the situation.
by emmelaich 11y ago
It's quite possible that someone will come up with a good enough automatic 2->3 converter which alleviate the situation.
- Spiritus 11y ago2to3 (comes bundled with Python) will do some of the work for you.
- ProblemFactory 11y agoThere are converters, and it's not too difficult to even write code that runs in both Python 2 and 3. The main roadblock in upgrades is unicode text vs bytes handling. Python2 was lax about using bytes for text. You could do unicode and bytes properly if you really tried hard enough, but it took a conscious effort. So most people just used bytes for text, and hoped for the best (if the data is ASCII or UTF-8, it will work most of the time). Python3 is strict about the text vs bytes separation. Patching this into a program afterwards is a lot of work. But if your Python2 program already does unicode carefully in Python2 (unicode type internally everywhere, from __future__ import unicode_literals, explicit encode/decode when talking to external APIs), then you are 90% done with the upgrade to Python3.
- icebraining 11y agopython-modernize[1] tries to automatically make your codebase compatible with both Python 2 and 3, using 2to3 and six[2] underneath. I haven't tried it yet, though. [1] https://github.com/mitsuhiko/python-modernize https://github.com/mitsuhiko/python-modernize [2] https://pypi.python.org/pypi/six https://pypi.python.org/pypi/six
- brettcannon 11y agoArmin handed over development and now Modernize is actively developed at https://github.com/python-modernize/python-modernize https://github.com/python-modernize/python-modernize
- icebraining 11y agoOh, thanks!
- brettcannon 11y agoSee https://docs.python.org/3/howto/pyporting.html https://docs.python.org/3/howto/pyporting.html for the most modern approach to porting Python 2 code to Python 2/3 code.