What's the difference between the keywords 'python' and 'python3' in command lines?

I've seen two ways to open a python script using the commandline, these are:

python foo.py 

and

python3 foo.py 

I know, there are python2 etc, but what does python without a version do then and why did I see it recently?


You can install multiple versions of python simultaneously in your system. Currently, python versions 2.x.x and 3.x.x is installed in your system.

Python3 is installed alongside with python(2) because some apps may still have a dependency on older python(2).

So python will refer to version 2.x.x and python3 will refer to version 3.

You can confirm the versions by:

python --version
python3 --version

Multiple versions of Python can be installed alongside each other and which version of Python to use can be selected by the user. The command python starts the interactive Python 2.x interpreter and python3 starts the interactive Python 3.x interpreter. For example:

C:\Windows\system32> python
Python 2.7.15rc1 
>>> 2+3
5

Many Python packages are packaged in separate versions for Python 2.x and Python 3.x and can also be installed alongside each other.

Python can run scripts interactively in a REPL. A read–eval–print loop (REPL), also termed an interactive top level or language shell, is a simple, interactive computer programming environment that takes single user inputs (i.e. single expressions), evaluates them, and returns the result to the user. Installing IPython allows the user to run blocks of code and scripts interactively in a more user-friendly way. Installing IPython 2.x alongside IPython 3.x gives the user the capability of interactively running blocks of both Python 2.x code and Python 3.x code.