HELP?

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Sun Feb 3 09:46:08 EST 2002


----- Original Message -----
From: "Callum Golding" <Rave_Dj at btopenworld.com>


> I'm sorry to bother you, but i was wondering if you could give me a little
> advice. I've recently downloaded Python 2.2. Ive read a begginers guide to
> programming and tried creating a small program, I used the input function.
> Now as soon as I open the program it goes into dos and asks me the
question,
> and when i type in an anwser, dos shuts down. Now its really starting to
bug
> me. If you could give me some advice I would be real grateful. The program
I
> wrote is below; -

Fairly common problem.  You neglected to state your OS but I can easily
assume
Windows; note that many of us use other OS's, so you should always state
that.

You are running the script from Explorer, by double-clicking?  In that mode,
a console application (like python.exe) will open a "dos window" (actually
a Windows Console) and run in it.  When the program terminates, the window
closes (as you have noticed).

Two solutions:  First, run your script from the DOS prompt.  Do Start, Run,
"command", ENTER; or find MS-DOS Prompt under Start, Programs.  If you are
running NT, 2000, or XP, you can change "command" to "cmd" (don't type the
quotes in any case, they are there to tell you that the quoted material
is to be typed in).  Once in the DOS window, change directories to the
folder your script is in, and type

    python myscript.py

If you get a "Bad Command or Filename" message, you need your Python
directory
in your DOS PATH variable.  How to do this varies between 95/98 and
NT/2000/XP,
so you should tell us what you are using.

You could type:

    c:\python22\python myscript.py

if you installed Python 2.2 in the standard place, and that would work.

Second solution:  Add

    raw_input()

as the last line of your script.  Then, you will have to press ENTER to end
the script.

Learn to work at the command prompt.  It's a dying art.






More information about the Python-list mailing list