On Tue, Apr 3, 2018 at 9:00 AM, Kirill Balunov <kirillbalu...@gmail.com> wrote: > In fact, I do not really understand why the _py launcher_ way is easier or > better than `python3` or `python3.6` way even on Windows. There are already > `pip.exe`, `pip3.exe`, `pip3.6.exe` which solve the same problem, but they > are all redundant, when it is better to use `python3.6 -m pip ... ` or > currently `py -3.6 -m pip install ...`.
Because py.exe is really meant to solve a slightly different problem. On Unix if you have a .py script and you run it directly, without specifying which interpreter to use, the convention is to start the script with a shebang line, and the kernel will transparently use the interpreter specified there. Windows, however, doesn't respect shebang lines and instead associates programs with files by file extension. Here's the problem: Python 2 files have a .py extension. Python 3 files also have a .py extension. Windows doesn't allow both Python binaries to be associated with the same extension. So how can we set things up so that launching a Python file will invoke the correct Python version? To solve this, Python ships with py.exe and associates *that* with the .py extension. py.exe knows what Python versions are installed, and it inspects the shebang line to decide which one to run for this particular script. The fact that py.exe can also intelligently select versions from command line arguments is just an added bonus. -- https://mail.python.org/mailman/listinfo/python-list