Mike <m...@mhuffman.com> wrote:

> t does not; Windows associates applications with file extensions.
> However, I have used something like this to get something like the
> Unix shebang behavior:
> 
> @echo off
> rem = """ ver26.bat: Python 2.6
> C:\Python26\python -x %~f0 %*
> goto END
> rem """
> # ver26.py wrapped in ver26.bat to mimic Unix #! behavior
> 
> import sys
> print sys.version
> 
> rem = """
>:END
> pause
> rem """
> 

That seems overkill. This does pretty much the same thing:

        @(C:\Python26\Python -x %~f0 %* || pause) && goto:EOF
        import sys
        print sys.version
        # raise RuntimeError # uncomment to trigger the 'pause'

EOF is a special label which may be used to exist a CMD file without having 
to explicitly define it. As I wrote it above the pause is executed only if 
the script exists with a non-zero status.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to