How do I find executable files from the environment PATH variable?
matt_gerrans at hp.com
Thu Aug 8 00:24:56 CEST 2002
On Windows, the PATH + PATHEXT environment variables plus registered
associations and file types all play a part in what is an "executable."
The which.py in the tools\scripts directory just checks os.stat(), so it
misses a lot of things. I wrote a simple which.py that shows all the
possible culprits in the path (in the order in which they are found in the
current directory, then the path, of course), like so:
(as you can see, I've also setup things so that Python files can be run as
if they are executables (even without the .py -- that is what PATHEXT
This is, of course, all platform-dependent, but I don't think this stuff can
be handled in a very platform-universal way (without the LCD effect), so a
platform check would be required.
More information about the Python-list