Python Programming/Python 2 vs. Python 3

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Python 3 was created incompatible with Python 2.

One noticeable difference is that in Python 3, print is not a statement but rather a function, and therefore, invoking it requires placing brackets around its arguments. Differences with deeper impact include making all strings unicode and introducing a bytes type, making all integers big integers, letting slash (/) denote a true division rather than per default integer division, etc.; for a compact overview, see Python wiki.

Python 2 code can be made ready for a future switch to Python 3 by importing features from __future__ module. For instance, from __future__ import print_function makes Python 2 behave as if it had Python 3 print function.

The end of support for Python 2.7 is currently set to 2020. Python 3 was first released in 2008.

A list of Python packages ready for Python 3 is available from py3readiness.org.

A survey conducted in 2018 by JetBrains and Python Software Foundation suggests significant adoption of Python 3 among Python users.

External links[edit]