Python 2 or 3?

Following the grand tradition of how my website works, here's something I wrote for another place and thought I could post it here too. It's my answer to the following question:

I'm learning Python from scratch and someone said Python 2 is more supported but Python 3 is newer. Which one should I choose?

Unless you specifically need something that's incompatible with Python 3, any new development should happen in Python 3.

  • We have known for many years that Python 2 support will end.
  • No new language features have been released for Python 2 in years, and they never will be.
  • Python 3 solves several long-standing problems with Python 2.
  • Most popular libraries and packages are in fact Python 3 compatible.
  • Starting now in Python 2 means you will definitely have to rewrite your code later.

It's not to say that everyone, everywhere must urgently rush to port all their code to Python 3. When you already know Python 2, have it installed, have a bunch of Py2 code, and use some libraries that don't work in Python 3, it doesn't make sense to migrate yet (though you will have to do so eventually).

If you're starting from scratch, Python 3 fixes many known problems of Python 2, adds several useful language features, and it is unquestionably the future of Python as a language. Unless your work absolutely requires a Python-2-only package, don't condemn yourself to facing the Python 3 hurdle in the future. Start in Python 3 now and avoid the hurdle!

The Python wiki has advice on this topic too.