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

Luke Paireepinart rabidpoobear at gmail.com
Thu Apr 5 08:52:11 CEST 2007


Kirk Bailey wrote:
> 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?

Kirk:
I addressed this issue in reply to your readlines question earlier:

""""""""""""""""""""""""""""""
Kirk Bailey wrote:
> #!C:\Python25\pythonw.exe
#! is only for Unix, it's pointless here.
""""""""""""""""""""""""""""""

Please don't skip over sections of  my replies, I occasionally do say 
useful things. ;)
-Luke


More information about the Tutor mailing list