[Tutor] windows and python and shebangs, oh my!

Kirk Bailey deliberatus at verizon.net
Thu Apr 5 03:28:21 CEST 2007


OK, in a script, we include a special statement telling the shell where 
to go find the interpeter. This is the first line of the script, and is 
a dpecial sort of comment, called informally the shebang. it looks like 
this:
#!C:\path\interpeterprogramname

In windows, this is for the current edition C:\python25\pythonw.exe
so the shebang is
#!C:\python\pythonw.exe

Well, gues what? looking at a little used program, inherited from an 
earlier edition, which pops up the manual for the wiki I am developing, 
the shebang was:
c:\python22\pythonw.exe

Notice it is 22. My installed version is 2.5... hmmm... the path 
indicated does not exist in this computer, and should trigger a error.

OK, I took out the path. It still worked. Hmmm...

OK, I renamed the interpreter file declared in the shebang to a non 
existent file name. it still worked. WHAT THE MERRY HELL?!?

At a loss, it then occurred to me that the program is a .py name 
extension. When the auto installer installed python it may have created 
an association between that name extension and the correct interpreter 
automatically, so a interpreter declaration line is not required in 
windows, unlike my beloved FreeBSD that critter my server on the web 
speaks with only a slightly obsolete accent. Hmmm...

So work with me, windows Pythonistas. CAN I rely on windows definitely 
and reliably having .py files associated with the windows python 
interpreter, so the script does not need a shebang declaration? Can I 
skip this part of the configure/install process of the application and 
count on it working reliably?

If so, my task of designing the autoinstaller script just got a LOT simpler.



-- 
Salute!
	-Kirk Bailey
           Think
          +-----+
          | BOX |
          +-----+
           knihT

Fnord.


More information about the Tutor mailing list