Windows and python execution

Peter Hansen peter at engcorp.com
Tue Dec 27 06:39:48 EST 2005


Peter Hansen wrote:
> BartlebyScrivener wrote:
>>>>What you need to do is include the following line in autoexec.bat:
>>>>set .py=c:\python24\python.exe
>>
>>Whatever works for you. I don't have that command in my autoexec.bat
>>file and my python scripts execute from any location because the
>>directory they are stored in is in my PATH variable.
...
> Merely adding the folder containing the EXE to PATH does *not* let you 
> avoid typing "python" before the script name, as your posts imply.

D'oh... okay, people (including me) are reading others' posts with 
preconceptions about what they are talking about in mind.

The PATHEXT thing is required to be able to type just "scriptname" 
_without_ the .py extension.  Alternatively, it appears there's yet 
another obscurely documented feature involving setting environment 
variables that resemble file extensions, as posted by others.  (Where do 
these things come from?  It's like Microsoft releases the OS, then 
periodically sends private emails to random people, pointing out obscure 
new features, so that they can tell others in some feeble effort to make 
using Windows look like a grassroots effort or something.  How are 
regular mortals supposed to find out about things like "set .py="?)

The ability to run the script with just "scriptname.py" comes from, I 
believe, having a file association set up with "ftype" and "assoc" or 
the equivalent registry entries.  For this to work from _any_ location 
one must have the folder containing the *script* in the PATH, as with 
any executable, while the path specified by FTYPE points to the Python 
executable.  (This ftype/assoc file association is set up by the 
standard installer, which is why it works for BartlebyScrivener).

-Peter




More information about the Python-list mailing list