Mark Carter <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]:
> Bengt Richter wrote: > >>>>And there is a PATHEXT environment variable, >>> >>>Aha. You'bve provided a significant clue. >>> >>>What you need to do is include the following line in >>>autoexec.bat: set .py=c:\python24\python.exe >>> >>>This will achieve the desired result. I'm suprised more people >>>don't use it. >> >> I wasn't aware of that syntax for set. What OS/platform/shell >> is that from? > > Windows XP, bog-standard default shell. UNIXers have it easy > because they can use the normal "shebang". > >> How did you go from the PATHEXT "clue" to the set command you >> specify > > I can't remember. It was a bit of luck, I think. I happened > upon: http://www.jpsoft.com/help/index.htm?exeext.htm > probably as a result of Googling for PATHEXT. > >> and decide >> not to set pathext, e.g., by something like >> set PATHEXT=%PATHEXT%;.py >> Does your set do the pathext and assoc and ftype all in one >> swell foop? > > Actually, I haven't figured out what PATHEXT is actually > supposed to "do". It seemed to me that Windows couldn't possibly > know that a py file should be started by python.exe, whereas my > set .py= ... > would. > > I had installed python 2.4 in the standard way, so py files were > already associated with python when you double-clicked them from > Explorer. Using my set meant that if I wanted to use py files > from the command line, I could just type out the script name > (you have to be in the right directory, of course), and it > works. Here's a snippit from my autoexec.bat files: > set PATH=C:\python24;%PATH% > set .py=c:\python24\python.exe > I should have asked which Windows version you had. My bad. On Win2k or XP, adding .py (for instance) to the PATHEXT variable means that you can execute "myNeatProgram.py" with this command-line: prompt>myNeatProgram Since .py appears in the PATHEXT variable, the system knows that .py files are executable, so it's not necessary even to specify them. What must happen, I suppose, is that the system looks for myNeatProgram.bat, myNeatProgram.com, myNeatProgram.exe, etc., until it hits upon myNeatProgram.py and proceeds to run it. So if you have a myNeatProgram.bat that appears earlier in your path than myNeatProgram.py does, the bat file is what gets run. -- rzed -- http://mail.python.org/mailman/listinfo/python-list