Python 2.7 or 3.6?

What’s the difference between Python 2.7 and 3.6? Which one should someone new to coding, like myself, use? These were really interesting questions that I didn’t know the answer to. So again I turned to the experts, the internet. Here’s what I found.

The official Python pages are a great place to start. The short summary is that Python 2.X is legacy and Python 3.X is the present and the future of the language. Python 2.7 was released in 2010 but will not be maintained past 2020. As of writing this, that means roughly 2 years, 2 months, 19 days and 5 hours until support for 2.7 ceases (PyCon 2020). Python 3.X is still in active development and has seen multiple releases since 2012, all of which had made improvements to the standard library. Many of the major modules (of which I have not had any experience yet) have also now been ported to run with Python 3.X. An additional point I can’t stress enough, Python 3.X is also recommended for newbies over 2.X!

So new and shiny is better? Not in all cases. As Python 2.X has been in use for a lot longer and there is slightly better library support for this version. In addition some current Linux distributions and Mac systems use Python 2.X by default. If I were an experienced programmer who was going to be working in an environment based on Python 2.X, learning Python 3.X would not be the best idea. Alternatively, if I were using a system running a module in Python 2.X without 3.X support, the same would apply.

As time goes on, the question of which version to adopt becomes less of a grey area. Most advice suggests to use Python 3.X. Python org states that the minority are with 2.X. Episode #145 of “talk python to me” actually discussed this subject and the consensus is that going into 2018, Python version 3 has become the answer to this question. I wanted to adopt Python to solve issues I’ve come across in my work. Python is not installed on any PCs at work so I wasn’t going to experience any backwards compatibility issues. All this in mind, Python 3.6.3 was the logical choice for me.

Here’s a little something that I’ve since discovered. If Python is not installed in your work environment, it’s very easy to package Python scripts into an executable (.exe) file by using the module ‘Pyinstaller’. Thus, python does not even need to be installed to run the script on another computer. Ideal for someone like me, introducing automated scripts to a non-coding environment– but that’s getting ahead of myself…

Resources:
https://wiki.python.org/moin/Python2orPython3
https://pythonclock.org/
http://www.pyinstaller.org/
https://talkpython.fm/