Newbie python query

David C. Ullrich ullrich at math.okstate.edu
Mon Apr 9 12:02:35 EDT 2001


On Mon, 9 Apr 2001 12:58:45 +1200, "Ben Hawkes"
<ben.hawkes at paradise.net.nz> wrote:

>Hi,
>
>I've just started using python on my win95 box, and i'm a bit stuck. I'm
>totally unsure on how to load a .py file into the interpreter and execute or
>compile it into an executable, HELP!

You can load it into the interpreter by adding a switch 

-i

to the command line. Where that command line goes depends
on how you're starting the thing; could be in the command
line for a shortcut, or you could do it through file associations
in the registry:

Start regedit and save [HKEY_CLASSES_ROOT\.py] to
a .reg file in case you decide to go back to the way things
were. Now take the following reg file:

REGEDIT4

[HKEY_CLASSES_ROOT\.py]
@="DUPythonFile"

[HKEY_CLASSES_ROOT\DUPythonFile]
@="DUPythonFile"

[HKEY_CLASSES_ROOT\DUPythonFile\DefaultIcon]
@="D:\\Python\\Py.ico"

[HKEY_CLASSES_ROOT\DUPythonFile\shell]
@="Edit"

[HKEY_CLASSES_ROOT\DUPythonFile\shell\Edit]

[HKEY_CLASSES_ROOT\DUPythonFile\shell\Edit\command]
@="c:\\ultraedit\\uedit32.exe %1"

[HKEY_CLASSES_ROOT\DUPythonFile\shell\Run(DOS)]

[HKEY_CLASSES_ROOT\DUPythonFile\shell\Run(DOS)\command]
@="c:\\python\\py.bat %1"

[HKEY_CLASSES_ROOT\DUPythonFile\shell\Initialize Interpreter]

[HKEY_CLASSES_ROOT\DUPythonFile\shell\Initialize Interpreter\command]
@="c:\\python\\python.exe -i %1"

change the paths to point to the Python installation, to the editor
you want to use, etc, then merge it into the registry. Now your
.py files should have three actions associated with them,
namely Edit, Run(DOS) and Initialize Interpreter. The last
one executes all the statements in the file and then gives
you an interactive prompt.

>Ben Hawkes
>
>




More information about the Python-list mailing list