Main differences between Python 2.7 and Python 3.7

João Henrique Machado Silva
The Polyglot Programmer
2 min readMay 23, 2019

I keep this one quick and to the point.

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.

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.

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.

Like the post? HOW ABOUT A CLAP?

--

--