A very, very newbie question :)

David C. Ullrich david_ullrich at my-deja.com
Wed Aug 23 14:43:29 EDT 2000


In article <39A41D7E.D865837D at earthlink.net>,
  The Jazz Singer <caitlin006 at earthlink.net> wrote:
> I've been following through on several online Python tutorials- (I've
> learned most of the MUD languages, HTML, DHTML, Java, JavaScript, and
> some C); and it's really a lot of fun! This is the first real building
> code that I've been doing, and it's going swimmingly.
> I do, however, have a question. You see, I've
> been putting my scripts on notepad, saving them as .py's, and opening
> them, whenever I want to run them as a test. Well, it works fine. But
> when I open it, it speeds through theprogram so fast that I don't even
> get a chance to see it before it
> closes (!)
> Any words of wisdom?

      There are various things you can do. Like

      Instead of associating .py files with python.exe you
can associate them with a batch file py.bat - something
like a one-line

C:\Python\python.exe "%1" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"

should do. The point is you get to set a lot of "Properties"
for that batch file - in particular there's a "Close on Exit"
box that you can un-check.

Or as someone else said, you can add various items to the
right-click menu for .py files by modifying the registry.
The best way to do that is through a .reg file, in my
opinion. I have a file py.reg that looks like this:

********************************************
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"REGEDIT4

[HKEY_CLASSES_ROOT\.py]
@="DUPythonFile"

[HKEY_CLASSES_ROOT\DUPythonFile]
@="DUPythonFile"

[HKEY_CLASSES_ROOT\DUPythonFile\DefaultIcon]
@="C:\\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"
*********************************************

(not including the "****************"'s.) You can probably
figure out how to modify that to do what you want - now
merge py.reg and you're set.

     The really right way to handle this sort of thing is to
have a little utility that will convert a file with a simpler
syntax, like for example the following py.dat:

DUPythonFile
C:\Python\Py.ico
.py
Edit
c:\ultraedit\uedit32.exe
Run(DOS)
c:\python\py.bat
Initialize Interpreter
c:\python\python.exe -i

into a reg file as above. The point being the dat file is
simple enough you can know the syntax is right just by glancing
at it, it's easy to modify. Then the utility generates the
right reg file (you might test the utility on a fake file type)
and the reg file lets you modify the registry without any
risk of bad stuff caused by accidental keystrookes...

--
Oh, dejanews lets you add a sig - that's useful...


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list