On 4/3/2018 11:43 AM, Ian Kelly wrote:
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

These are put in the pythonxy/Scripts directory. So they only work if the pythonxy/Scripts directory is on the path. But there really should only be 1 such directory on the path. Otherwise, the meaning of pip.exe and pip3.exe depends on the order of the multiple /Scripts directories.

are all redundant, when it is better to use `python3.6 -m pip ... ` or
currently `py -3.6 -m pip install ...`.

Because the last works with multiple python installations.

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.

I consider it essential, as I often run scripts with more than one version, so baking a version into the script is wrong.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to