maintain 2 versions of python on my computer
mike at mhuffman.com
Sat Jan 16 18:32:18 CET 2010
> On unix you would start the file with a "hashbang" e.g.
> Fraid I don't know if that works on XP though.
It does not; Windows associates applications with file extensions.
However, I have used something like this to get something like the
Unix shebang behavior:
rem = """ ver26.bat: Python 2.6
C:\Python26\python -x %~f0 %*
# ver26.py wrapped in ver26.bat to mimic Unix #! behavior
rem = """
rem = """ ver31.bat: Python 3.1
D:\Python31\python -x %~f0 %*
# ver31.py wrapped in ver31.bat to mimic Unix #! behavior
rem = """
I cannot remember where I first saw this, and don't think I have ever
seen it since. It seems like a bit of a hack, but I use it from time
to time when I cannot rely on Windows file associations. Perl has
a much cleaner way to accomplish the same thing for Windows (see the
pl2bat.bat script that ships with
Perl Windows distributions).
More information about the Python-list