py
is part of the Python launcher for Windows. It is a utility that acts as a wrapper for the different versions of Python that may be installed. Without arguments, it will run the default installed version, but you can also specify a version using command line arguments such as -2.6
or -3
. The py
command is intended for starting the Python interpreter from the command line.
On Unix-like systems such as OS X, the python launcher isn't needed and you invoke Python in the regular way using python
(default version) python3
(default version of Python 3.x) or python3.4
(specifically Python 3.4). (Or any other specific version.) So the answer to your question is that those commands have more or less the same result, but py
is Windows-only.
The Python launcher for Windows was introduced in Python 3.3 and is documented here. The reason for introducing it was to make it possible to run Python programs under specific versions, which became important when Python 3 was introduced and you could no longer rely on compatibility of your code with the default version. Even if you had both Python 2 and 3 installed, scripts with a .py
extension would still run using the default version, which would always be the last installed version. The launcher solved this problem on Windows without breaking other platforms on which this wasn't a problem. If you are interested in the details, check out PEP 397 and this blog entry.