Porting Python 2 Signal to Python 3A¶
With Python 3 are the continuing future of Python while Python 2 remains in active incorporate, it is good to have your venture designed for both significant releases of Python. This guide is supposed to support work out how better to supporting both Python 2 3 simultaneously.
If you are searching to port an extension module in the place of pure Python laws, be sure to discover Porting Extension Modules to Python 3 .
If you wish to learn one core Python creator’s accept precisely why Python 3 came into existence, you can read Nick Coghlan’s Python 3 Q A or Brett canon’s exactly why Python 3 prevails.
The small ExplanationA¶
Incorporate Pylint to make sure you do not regress on your own Python 3 support ( python -m pip install pylint )
Usage caniusepython3 to discover which of one’s dependencies are stopping their use of Python 3 ( python -m pip install caniusepython3 )
Once your dependencies are not any longer stopping you, use steady integration to ensure that you stay appropriate for Python 2 3 (tox will try against numerous variations of Python; python -m pip install tox )
Consider utilizing elective static means examining to be sure your kind practices works in both Python 2 3 (example. usage mypy to test your typing under both Python 2 Python 3; python -m pip install mypy ).
Mention: utilizing python -m pip apply guarantees the pip your invoke could be the one set up for your Python presently in use, whether it is a system-wide pip or one put in within an online planet .
DetailsA¶
A key point about support Python 2 3 simultaneously is you can begin today! Regardless if your dependencies aren’t promoting Python 3 yet that will not mean you cannot modernize their signal now to guide Python 3. Many modifications required to help Python 3 trigger cleaner rule using new tactics even in Python 2 rule.
Another a key point is modernizing the Python 2 rule to also support Python 3 is largely automated for you personally. You might have to make some API behavior because of Python 3 clarifying text information versus binary information, the lower-level tasks are now primarily accomplished for both you and hence can no less than take advantage of the robotic variations straight away.
Keep those tips in mind even though you keep reading concerning specifics of porting your signal to support Python 2 local hookup app Washington DC 3 simultaneously.
Shed help for Python 2.6 and olderA¶
Even though you could make Python 2.5 use Python 3, it’s simpler should you only have to work with Python 2.7. If losing Python 2.5 isn’t an option then your six venture can help you supporting Python 2.5 3 at the same time ( python -m pip install six ). Do recognize, though, that almost all the projects placed in this HOWTO will not be available to you.
If you are in a position to miss Python 2.5 and old, then your required modifications to your laws should always appear and feel like idiomatic Python signal. At the worst you’ll have to incorporate a work rather than an approach sometimes or must import a function as opposed to using an integrated one, but or else the general transformation cannot feeling foreign to you.
You should strive for only encouraging Python 2.7. Python 2.6 has stopped being easily recognized and so just isn’t obtaining bugfixes. This simply means you are going to need to work around any dilemmas you come across with Python 2.6. There are also some knowledge discussed inside HOWTO which do not support Python 2.6 (e.g., Pylint), and this will become more common as time goes on. It’ll simply feel simpler for you any time you merely offer the variations of Python that you must support.