Please start migrating your existing your existing Python 2 code to Python 3. Python 3 is not backwards compatible with Python 2, so your code may need to be adapted.
Python 2 series End Of Life is set to 1st of January 2020.
Introduction
Python 2.7 was released on July 2010. Being the last of the 2.x series, 2.7 has had an extended period of maintenance. Specifically, 2.7 will receive bugfix support until January 1, 2020. After the last release, 2.7 will receive no support.
Python 3.0 was released on December 2008. It was designed to rectify fundamental design flaws in the language. The changes required break backwards compatibility with the 2.x series, which necessitated a new major version number.
Major changes
Changing
print
so that it is a built-in function, not a statement. This made it easier to change a module to use a different print function, as well as making the syntax more regular. In Python 2.6 and 2.7print()
is available as a builtin but is masked by the print statement syntax, which can be disabled by enteringfrom __future__ import print_function
at the top of the file.- Removal of the Python 2
input
function, and the renaming of theraw_input
function toinput
. Python 3'sinput
function behaves like Python 2'sraw_input
function, in that the input is always returned as a string rather than being evaluated as an expression. - Moving
reduce
(but notmap
orfilter
) out of the built-in namespace and intofunctools
(the rationale being that operations using reduce are expressed more clearly using an accumulation loop). - Adding support for optional function annotations that can be used for informal type declarations or other purposes.
- Unifying the
str
/unicode
types, representing text, and introducing a separate immutablebytes
type; and a mostly corresponding mutablebytearray
type, both of which represent arrays of bytes. - Removing backward-compatibility features, including old-style classes, string exceptions, and implicit relative imports.
- A change in integer division functionality: in Python 2,
5 / 2
is2
; in Python 3,5 / 2
is2.5
. (In both Python 2 (2.2 onwards) and Python 3,5 // 2
is2
).
Subsequent releases in the Python 3.x series have included additional, substantial new features; all ongoing development of the language is done in the 3.x series.
Porting your code to python 3
For a complete reference and advise, see https://docs.python.org/3/howto/pyporting.html
It is possible to write code that works for both major versions of Python, and it is the recommended strategy for maximum compatibility and flexibility. See the following page for a comprehensive list of compatible idioms. The easiest way to make sure your python 2 code can run on python 3 is to use automatic conversion tools such as futurize. Even if they are not perfect in all cases, they should take care of adapting the vast majority of your code base without too many bugs introduced. Futurize will also generate code that is compatible with both editions. See the quick start guide for instructions on how to use this tool.