Mailing List Archive

How do you make clickable Python/Win9x scripts?
Is there a way to make a Python script file a clickable .BAT file in
Win9x?
It's possible with Perl, and looks something like this:
@rem = '
@echo off
C:\perl\perl5\bin\perl -x -S %0 %1%
goto endofperl
@rem ';
#!.\perl\bin\perl -w

print "Hello World!\n";
__END__
:endofperl

The above Perl file would be named world.bat.
How do you make clickable Python/Win9x scripts? [ In reply to ]
From: Rob <vaton@postoffice.pacbell.net>

Is there a way to make a Python script file a clickable .BAT file in
Win9x?
It's possible with Perl, and looks something like this:
@rem = '
@echo off
C:\perl\perl5\bin\perl -x -S %0 %1%
goto endofperl
@rem ';
#!.\perl\bin\perl -w

print "Hello World!\n";
__END__
:endofperl

The above Perl file would be named world.bat.
How do you make clickable Python/Win9x scripts? [ In reply to ]
From: "Tim Peters" <tim_one@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
How do you make clickable Python/Win9x scripts? [ In reply to ]
[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
How do you make clickable Python/Win9x scripts? [ In reply to ]
I have an NT hack - not sure about Win95. Note that this
does NOT require registry/admin access, as far as I know.

1. Make sure the .pyc version of your file exists using CLI
"python.exe compileall.py $cwd" or whatever.

2. Create a new filetype (Python Executable), pointing to
your python binary, with suffix .pyc.

3. Add .pyc to CMD_SUFFIXES (not 100% sure)

4. Drop a link to the pyc file on your desktop.

5. Pass script parameters using standard Win hack.

6. I tried a PIF file but gave up. Looked like overkill.

Sue.
How do you make clickable Python/Win9x scripts? [ In reply to ]
From: Sue <smalleys@gte.net>

I have an NT hack - not sure about Win95. Note that this
does NOT require registry/admin access, as far as I know.

1. Make sure the .pyc version of your file exists using CLI
"python.exe compileall.py $cwd" or whatever.

2. Create a new filetype (Python Executable), pointing to
your python binary, with suffix .pyc.

3. Add .pyc to CMD_SUFFIXES (not 100% sure)

4. Drop a link to the pyc file on your desktop.

5. Pass script parameters using standard Win hack.

6. I tried a PIF file but gave up. Looked like overkill.

Sue.