Win32 : Making script.py executable in DOS box
Remco Gerlich
scarblac-spamtrap at pino.selwerd.nl
Tue Jul 4 09:15:50 EDT 2000
Neo Brave wrote in comp.lang.python:
> In article <WzI75.5714$Tb7.31718 at news-server.bigpond.net.au>,
> "Mark Hammond" <MarkH at ActiveState.com> wrote:
> > Under Windows NT or Win2k, you can use the PATHEXT environment
> > variable. Simply add ".py" to the semi-colon sep'd list of
> > extensions, and off you go!
>
> Great, thats a help for NT, but I also want to do this on Win98 :-).
There is another trick (originally by Bruce Eckel). Name your Python
file ".bat" instead of ".py" and use the following hack:
@echo off
rem = """
rem Run python on this bat file. Needs the full path where
rem you keep your Python files. The -x causes Python to skip the first
rem line of the file:
python -x c:\python\\"%0".bat %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofpython
rem """
# The Python program goes here:
print "hello, python"
# For the end of the batch file:
rem = """
:endofpython
rem """
Or just make a .bat file that goes with your .py file and calls python
for it...
--
Remco Gerlich, scarblac at pino.selwerd.nl
3:12pm up 120 days, 3:25, 5 users, load average: 0.33, 0.29, 0.20
More information about the Python-list
mailing list