What Python version can you please recommend for a long-term (years) project? Should one use 2.6+ or 3.x is already stable? (only standard libraries are required)
UPDATE: according to the answers below, Python 3.x still has critical bugs. Please also see Python's list of bugs.
To make your project be single-source Python 2/3 compatible, the basic steps are: Only worry about supporting Python 2.7. Make sure you have good test coverage (coverage.py can help; python -m pip install coverage ) Learn the differences between Python 2 & 3.
Python 3 is more in-demand and includes a typing system. Python 2 is outdated and uses an older syntax for the print function. While Python 2 is still in use for configuration management in DevOps, Python 3 is the current standard. Python (the code, not the snake) is a popular coding language to learn for beginners.
If you want to determine whether Python2 or Python3 is running, you can check the major version with this sys. version_info. major . 2 means Python2, and 3 means Python3.
This is why you should use Python 3.x:
Python 2.x:
>>>True = False
>>>True
False
Python 3.x:
>>> True = False
File "<stdin>", line 1
SyntaxError: assignment to keyword
Source: Strangest language feature
Prejudice: But so many packages are not Python 3 ready yet
This is (a) not true (source) and (b) not important to a beginner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With