Some people think Python 2.x and 3.x are incompatible, different languages.


Here are some differences between 2.x and 3.x:

The print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement (PEP 3105).

This means most Python 2.x programs are definitively incompatible with 3.x, just because of that.

Python 2:

print "Hello world!"

Python 3:

print ("Hello world!")

Some well-known APIs no longer return lists. k = dict.keys(); k.sort() no longer works, as well as dict.iteritems(), dict.iterkeys() and dict.itervalues().

Python 3.0 uses the concepts of text and (binary) data instead of Unicode strings and 8-bit strings. All text is Unicode; however encoded Unicode is represented as binary data. The type used to hold text is str, the type used to hold data is bytes.

As a consequence of this change in philosophy, pretty much all code that uses Unicode, encodings or binary data most likely has to change.


Sometimes, you can’t mix Python 2 code with Python 3 code. Especially, don’t try to use different libraries that work with different major Python versions; it is not likely to work.


Although most companies are moving to 3.x, some libraries still continue to support Python 2. A few might not support Python 3 at all.


Useful links:


Now Python 3 has been released 11 years ago, and Python 2.7 is still supported (although end of support is for January 1st, 2020). How should these be considered “different” languages?