How do I make a Python .bat executable file?
Robert Shockley
vaton at postoffice.pacbell.net
Mon Dec 27 21:35:39 EST 1999
More information about the Python-list mailing list
Mon Dec 27 21:35:39 EST 1999
- Previous message (by thread): IPC8 Developers Day
- Next message (by thread): How do I make a Python .bat executable file?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thanks a lot for the info, your solution is the one I was looking for (a windows equivalent to the pound-bang trick ~Rob~ Gordon McMillan wrote: > Robert Schockley writes: > > > What kind of 'wrapper' is needed to make a python script an > > executable .bat file in Windows? Is the she-bang (#!/...) line > > required? I would appreciate any help. ~Rob~ > > shebang does nothing on WIndows. > > Most people use the file extension association (.py -> > python.exe) which the installer sets up for you. Unfortunately, > file redirection is broken (in general) when using file > associations, so: > >python myscript.py >out.txt # works > >myscript.py >out.txt # doesn't > > The more direct equivalent of the shebang trick would be (this > version courtesy of Bruce Eckel): > ---------------------------------------------------------- > @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 > rem the first line of the file: > python -x c:\aaa\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 > -------------------------------------------------------------- > ...which I never use because none of my editors are smart enough to > syntax colorize a Python script with a .bat extension. > > - Gordon
- Previous message (by thread): IPC8 Developers Day
- Next message (by thread): How do I make a Python .bat executable file?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list