How to get the Python version on your system#

Getting the version number of your Python installation is not as straightforward as you might have guessed. But once you get the pythonic way of doing things, the implementation starts to make sense.

Open a Python shell and type the following:

>>> import sys
>>> sys.version[:5]


  • What would happen if you just do sys.version instead of sys.version[:5]?
  • What is the pythonic way?
  • Type import this at the Python console.
  • Is there any other way to know the Python version?
Tweet this | Share on LinkedIn |