Python 2 or 3?

The Python programming language is almost finished with a long-term transition from version 2 to version 3. New programmers often have questions about which version they should learn. It can be confusing to hear that Python 3, which was originally released in 2008, is still not the default installation on some operating systems such as macOS. However, that situation is rapidly changing as the final version 2 release, Python 2.7, is approaching its end-of-life that is definitively scheduled for January 1, 2020.

The simple answer right now is: learn Python 3, specifically the latest version which as of October 2019 is Python 3.7. If for some reason you absolutely have to learn Python 2, for example because your employer is working on a bunch of legacy code, you will be able to transfer the majority of your knowledge from Python 2 right into Python 3. Likewise, you will still be able to read and write Python 2 code if you start with Python 3.

There are enough great resources out there that will teach you to code in version 3 without any prior version 2 experience. Python 3 is the future and you will not regret starting with the latest version of the programming language.

There is one small caveat to the recommendation to go full-on Python 3. You may infrequently come across lesser-used open source code libraries that were originally written in Python 2 that do not completely support Python 3. That was the case before 2019 with DevOps configuration management tools such as Fabric or Ansible. However, those libraries now support Python 3 and the usage problems that were frequent in years past are now typically not a concern. Knowing how to upgrade Python 2 libraries to 3.x is still a useful skill to apply at the edges of the Python open source community.

Visualizations and Projects

Since upgrading from Python 2 to 3 has been such a huge undertaking within the community, many projects have sprung up to make the transition easier.

  • six is a 2/3 compatibility library that is a dependency for many popular Python projects to make it easier to support both Python 2 and 3 at the same time.

  • Python 3 Readiness is a visualization of which most popular 360 libraries (by downloads) are ready to be used with Python 3.

  • The Python clock counts down the time until Python 2.x is no longer maintained. While Python 2's retirement may still seem a long time away, it can take a lot of time and effort to migrate existing application to the modified syntax in 3.x.

Porting to Python 3 resources

Moving an existing codebase to Python 3 from 2 can be a daunting task, These resources were created by fellow developers who've previously gone through the process and have advice for making it less painful.

Python 2 to 3 resources

The following resources will give you more context on how the community feels the transition from Python 2 to 3 is going, as well as why you should upgrade as soon as possible.

What's next now that you know about Python versions?

What editor should I use to code my Python app?

I want to learn how to code a Python web application using a framework.

Show me a list of the best Python learning resources.

Matt Makai 2012-2022