Beginner's question...

Jeff Shannon jeff at
Fri Nov 23 23:10:04 CET 2001

Power-Tech wrote:

> I am a very newby at phyton, actually I started messing with it two days
> ago. I have a
> question that may be so dumb that I was afraid of posting in the
> mailgroup, could anyone answer me or direct me to someone who can?
>  The problem is:
> I create a small program with the Python IDLE gui, save it as a .py
> file, when I double click to open the file, a DOS window opens but
> closes immediately, without running the program, or if it is a
> calculating program, as soon as I type something, the window closes.
> I am using Windows 98 OS.
> Thanks for your reply...
> Willie

The program *is* running, it's just that the DOS window closes as soon as
the program finishes--before you've had a chance to see the result.  (Is
this in the FAQ?  If not, it probably should be...)  There are a couple of
ways to deal with this problem.

1.  Run the program within IDLE.  I don't use IDLE so I'm not sure exactly
where to find it (probably in the file menu), but there is an option to run
a script file within IDLE's interactive window.

2.  Open a regular DOS window, cd to the directory of your script, and run
it by typing "python".  This way, since the window is separate
from the Python program, it won't close when the program is finished.  If
you're doing repeated runs of the same script, you can run DOSkey and then
you can repeat the command with up-arrow.

3.  At the very end of your script, add this line:

    raw_input("Press Enter to Finish")

This will prompt for an enter before the script ends, and your DOS window
will stay open until it gets that enter.

Hope this helps...

Jeff Shannon
Credit International

More information about the Python-list mailing list