This time we visit the topic “Should I use Python 3 as it is the latest version or should I stick to Python 2 because most of the internet says so?”

According to the usual Python release schedule, Python 3.7 will continue to be supported until at least Python 3.9 is released – probably late 2019, or early 2020.

🐍 Python 2.7

  • 20 years old
  • Print as a statement – not a function so unusable in lambdas.
  • Difference between Ascii and Unicode strings
  • Magic interpretation of text from ‘input’ function
  • many function build lists (range, filter, map, etc) so have potentially large ‘spin up’ times.
  • Only getting security/emergency bug fixes currently.
  • No bug fixes at all from Jan 2020.
  • By default division rounds down.

🐍 Python 3.7

  • Produced in late 2018.
  • print is function so usable in lambdas.
  • All strings are Unicode
  • No magic interpretation of text from ‘input’ function – program must explicitly convert its data.
  • All built-in functions build generators (range, filter, map, etc) so no large ‘spin up’ times.
  • Security and maintenance bug fixes currently.
  • By default, division is floating point.
  • Lots of features from the Python 3 versions :
    • Data classes
    • Reworked threading and subprocess libraries.
    • Type hinting
    • Optimised dictionaries
    • Faster interpretation.

Libraries

The main pro Python 2 argument is that every library ever is written for it and if one switches to Python 3 won’t be able to find and use any of them. I believe this argument is quite outdated as Python 3 is now 10 years old and many libraries are now updated and functional. Some teams even start a project and in case the needed library is missing they code it, document and upload it. Very kind of them, isn’t it?
Right now the only libs you can’t find are the really obscure and unpopular ones. But if you are lucky one of the teams mentioned above will stumble on them and make it available to the rest of us!

Conclusion

In short – don’t start a new project in Python 2.7, unless you have a very specific need to do so (i.e. you know you need a 3rd Party library which doesn’t support Python 3).

if you have been taught Python 2 – then moving from Python 2 to Python 3 (for the developer) is relatively easy; there isn’t a whole lot to re-learn.