Entry
How do you make clickable Python/Win9x scripts?
Jul 5th, 2000 10:00
Nathan Wallace, Hans Nowak, Snippet 103, Tim Peters
"""
Packages: operating_systems.windows
"""
"""
> 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:
------------->8----snip-----------------------------------------"""
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
:'''
"""----------------------->8-----snip-------------------------------
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
"""