[Tutor] Newbie question

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Tue Nov 22 21:19:10 CET 2005



On Tue, 22 Nov 2005, Douglass, Erik wrote:

> I am trying to follow some online first timer tutorials, and I am
> writing the practice scripts in notepad (only w32 at work :-()..  I save
> the script with a .py extension, and when I run it it opens for a brief
> moment in a command prompt then closes before I even have a chance to
> see what it says.  This may seem trivial, but Python also happens to be
> my first language so this is all new to me.  Using Python 2.4.2

Hi Erik,

No problem.

What's happening is that Windows is closing down any program that's
finished.  Usually, that's what you want, except while you're learning how
to program.  Most of the programs you will be writing will be short,
terminate quickly, and close down before you can see your program's
results!  *grin*


If you run your programs through IDLE, you should be able to see them run
to completion without closing down.  I wrote an introduction to IDLE here:

    http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html

It's a little outdated, but most of the information there is still
relevant.  (The menu option for running scripts now lives in the Module
menu, I think.)


One other way to get around the program-terminating-closes-window problem
is to keep your program from terminating.  Some people will add a last
statement to their program, like the infamous:

######
raw_input("Please press enter to continue...")
######

which should pause until the user presses the enter key.


Best of wishes to you!



More information about the Tutor mailing list