Paul Moore <p.f.mo...@gmail.com> added the comment:

Well, I'm not convinced that using `shutil.which` is the right answer for 
anything other than "python". And even there, I'd recommend using 
`sys.executable` over `shutil.which` in pretty much every case.

My view is that if we ignore the "weirdness" introduced by the redirector[1], 
for everything else `subprocess` is fine - it searches for the executable using 
the normal platform semantics. That's nearly always the same across platforms, 
and when it isn't, users may well prefer consistency with the platform over 
identical cross-platform behaviour. And if they *do* want cross-platform 
consistency, at the cost of occasional differences between their program's 
behaviour and (for example) the shell, then they have `shutil.which` available.

Saying that `subprocess` follows platform semantics is easy, and clear. People 
who need to know platform details can find them out. People who want 
Python-defined cross-platform semantics have `shutil.which`.

That's the basis on which I feel that documenting the Windows rules is 
unnecessary. Also, why would we document the Windows rules, but not the POSIX 
rules? They are arguably just as strange to someone who doesn't know them.

[1] I would characterise that weirdness as being that the redirector impacts 
the behaviour of how the platform locates the "python" command under the 
platform search rules of the platform the redirector is used on - even though 
we don't document the behaviour of the redirector so the user cannot infer the 
actual rules without knowing implementation details.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42041>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to