Python 2 is ending, we need to move to Python 3 | free online courses

Python 2 is ending, we need to move to Python 3

Python 2 is ending, we need to move to Python 3

Python 2 is ending, we need to move to Python 3

  • by admin
  • Programming

Python is a great language that lets us quickly develop new features and enables contributions from a large community.  But Python 2 is coming to its end of life.  There will be no more bug fixes to Python 2 after January 1, 2020. We have a large task ahead of us.  Python 3 is not backward-compatible with Python 2, so we have to convert the code to run on it.

Open edX has nearly a million lines of Python code, and they all have to run on Python 3 by the end of the year. Much of the work is not hard, it’s just extensive, and can’t all be done automatically. 

Briefly: these are small chunks of work, each of which will move us closer to full Python 3 compatibility.  They are designed to be achievable and uncontroversial so that contributing the work is made easier.

Python 2

Published in late 2000, Python 2 signalled a more transparent and inclusive language development process than earlier versions of Python with the implementation of PEP (Python Enhancement Proposal), a technical specification that either provides information to Python community members or describes a new feature of the language.

Additionally, Python 2 included many more programmatic features including a cycle-detecting garbage collector to automate memory management, increased Unicode support to standardize characters, and list comprehensions to create a list based on existing lists. As Python 2 continued to develop, more features were added, including unifying Python’s types and classes into one hierarchy in Python version 2.2.

Python 3

Python 3 is regarded as the future of Python and is the version of the language that is currently in development. A major overhaul, Python 3 was released in late 2008 to address and amend intrinsic design flaws of previous versions of the language. The focus of Python 3 development was to clean up the codebase and remove redundancy, making it clear that there was only one way to perform a given task.

Major modifications to Python 3.0 included changing the print statement into a built-in function, improve the way integers are divided, and providing more Unicode support.

At first, Python 3 was slowly adopted due to the language not being backward compatible with Python 2, requiring people to make a decision as to which version of the language to use. Additionally, many package libraries were only available for Python 2, but as the development team behind Python 3 has reiterated that there is an end of life for Python 2 support, more libraries have been ported to Python 3. The increased adoption of Python 3 can be shown by the number of Python packages that now provide Python 3 support, which at the time of writing includes 339 of the 360 most popular Python packages.

Python 2.7

Following the 2008 release of Python 3.0, Python 2.7 was published on July 3, 2010, and planned as the last of the 2.x releases. The intention behind Python 2.7 was to make it easier for Python 2.x users to port features over to Python 3 by providing some measure of compatibility between the two. This compatibility support included enhanced modules for version 2.7 like unittest to support test automation, argparsefor parsing command-line options, and more convenient classes in.collections

Because of Python 2.7’s unique position as a version in between the earlier iterations of Python 2 and Python 3.0, it has persisted as a very popular choice for programmers due to its compatibility with many robust libraries. When we talk about Python 2 today, we are typically referring to the Python 2.7 release as that is the most frequently used version.

Python 2.7, however, is considered to be a legacy language and its continued development, which today mostly consists of bug fixes, will cease completely in 2020.

Key Differences

While Python 2.7 and Python 3 share many similar capabilities, they should not be thought of as entirely interchangeable. Though you can write good code and useful programs in either version, it is worth understanding that there will be some considerable differences in code syntax and handling.

Below are a few examples, but you should keep in mind that you will likely encounter more syntactical differences as you continue to learn Python.


In Python 2, print is treated as a statement instead of a function, which was a typical area of confusion as many other actions in Python requires arguments inside of parentheses to execute. If you want your console to print out Sammy the Shark is my favorite sea creature in Python 2 you can do so with the following print statement:

print "Sammy the Shark is my favorite sea creature"

With Python 3, print() is now explicitly treated as a function, so to print out the same string above, you can do so simply and easily using the syntax of a function:

print("Sammy the Shark is my favorite sea creature")

This change made Python’s syntax more consistent and also made it easier to change between different print functions. Conveniently, the print() syntax is also backward-compatible with Python 2.7, so your Python 3 print() functions can run in either version.

Division with Integers

In Python 2, any number that you type without decimals is treated as the programming type called integer. While at first glance this seems like an easy way to handle programming types, when you try to divide integers together sometimes you expect to get an answer with decimal places (called a float), as in:

5 / 2 = 2.5

However, in Python 2 integers were strongly typed and would not change to a float with decimal places even in cases when that would make intuitive sense.

When the two numbers on either side of the division / symbol are integers, Python 2 does floor divisionso that for the quotient x the number returned is the largest integer less than or equal to x. This means that when you write 5 / 2 to divide the two numbers, Python 2.7 returns the largest integer less than or equal to 2.5, in this case 2:

a = 5 / 2
print a



To override this, you could add decimal places as in 5.0 / 2.0 to get the expected answer 2.5.

In Python 3, integer division became more intuitive, as in:

a = 5 / 2



You can still use 5.0 / 2.0 to return 2.5, but if you want to do floor division you should use the Python 3 syntax of //, like this:

b = 5 // 2



This modification in Python 3 made dividing by integers much more intuitive and is a feature that is not backwards compatible with Python 2.7.


Python is a versatile and well-documented programming language to learn, and whether you choose to work with Python 2 or Python 3, you will be able to work on exciting software projects.

Though there are several key differences, it is not too difficult to move from Python 3 to Python 2 with a few tweaks, and you will often find that Python 2.7 can easily run Python 3 code, especially when you are starting out. You can learn more about this process by reading the tutorial How To Port Python 2 Code to Python 3.

It is important to keep in mind that as more developer and community attention focuses on Python 3, the language will become more refined and in-line with the evolving needs of programmers, and less support will be given to Python 2.7.


Reference Links:

Tags: Python