Windows and python execution

BartlebyScrivener rpdooling at gmail.com
Wed Dec 28 21:52:54 EST 2005


Some of the confusion probably comes from which installation people
use. I used the latest ActiveState distribution of Python. As one of
the other posters observed it automatically adds the .py extension in
the PATHEXT system variable. At least I didn't put it there. Then, as
we've discussed, as long as the directory containing your scripts is in
the path, you can type nothing by "myscript.py" at the command line and
your script will execute from any location on the machine.

rpd

Peter Hansen wrote:
> 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