How do you make clickable Python/Win9x scripts?

Tim Peters Tim.Peters at p98.f112.n480.z2.fidonet.org
Fri Jul 2 18:03:15 EDT 1999


From: "Tim Peters" <tim_one at email.msn.com>

[Rob]
> Is there a way to make a Python script file a clickable .BAT file in
> Win9x?

This kind of thing is the best I've ever come across:

rem=''' Here's a cheery greeting you can't get rid of, so use it
@echo off
:any other bat cmds you'd like to do first
:and then execute python on this file:
%PATH_TO_YOUR_PYTHON_DIR%python %0
goto endofpython
'''

name = raw_input("What's your name? ")
print "Hi,", name

rem = '''
:endofpython
:any other bat cmds you'd like to do afterwards
:'''

The batcrap is hidden from Python in multiline triple-quoted strings
assigned to "rem", the initial lines of which W9X treat as comments.  Note
the use of label notation (:''') to hide the final string closer from the
bat processor.  BTW, you're usually better off starting bat comments via ":"
than "rem"!  To understand why, try sticking

: <hi>

in one bat file and

rem <hi>

in another <wink>.

command.com-leaves-the-teensiest-bit-to-be-desired-ly y'rs  - tim







More information about the Python-list mailing list