[Tutor] Shebang (#!) in the first line of a python script
alan.gauld at btinternet.com
Tue Oct 13 10:01:52 CEST 2009
"Katt" <the_only_katala at verizon.net> wrote
> Okay. So if I were to place the following in my Windows XP py v.2.6.2 :
> $ (name of python script)
> Then as long as python was in my path I would be able to type the name of
> the script like a Dos batch file (ex: lowertoupper.py or lowertoupper)
> instead of having to type python lowertoupper.py? And it will run as
The shebang line does nothing on Windows, it is just a comment.
Windows uses the file extension so, provided you end the file in .py,
you can just type in the name of the script and Windows will use the
file association to find the interpreter.
This is a somewhat fragile mechanism and if you have two versions
of Python installed or the associations get broken it may fail but most
of the time it works fine.
Author of the Learn to Program web site
More information about the Tutor