On Mon 23 Sep 2019 at 11:32:46 (-0400), Greg Wooledge wrote:
> On Sun, Sep 22, 2019 at 05:21:27PM +0200, Thomas Schmitt wrote:
> > PATH is a convention of shells like bash or dash, not of Python.
> > In your examples it lets the shell parser find /usr/bin/python from
> > "python".
> 
> It's also used by some of the libc exec wrappers.  Specifically,
> the ones with "p" in their names: execlp(), execvp() and execvpe().
> 
> I'd be rather surprised if there's *no* function in Python that uses
> the PATH variable.  I'm not a Python developer, but I'm sure it has
> some features for running external programs, and I'd bet that at least
> one of those features has the option to search PATH for programs.

Yes, Python has functionality that exactly parallels those wrappers,
both as exec and spawn. These appear to use the PATH in finding the
programs to run, as does the recommended module "subprocess". So
Thomas might have been more complete by writing "shells like bash or
dash, or the underlying OS".

I would still distinguish use of PATH for finding external programs
from the business of processing arguements to find the script for
python to run. That's internal to Python, and I can find no use of
the PATH environment variable internally at all. All of the Python
environment variables are named PYTHON….

Cheers,
David.

Reply via email to