DOS problem (simple fix??)

G

Gavin Bauer

My DOS window (running in windows ME) closes the second it finishes
running my programs. As you can imagine, this makes it hard to see the
results. I've gotten in the habit of putting raw_input("Press enter to
exit") at the end of every program, and in addition to being pain in
the butt, it often fails to work. Being new to programming in general,
I make more mistakes than most people. My programs often have errors
before they get to my raw_input command. They then display the error
and immediately close. It is naturally a lot easier to fix an error
when you know what the error is. This makes debugging even more
annoying than it ordinarily would be, if you can imagine that. I've
heard that it should be a simple preference fix, but I've asked around
and no one seems to know how.

Thank you, and please make all answers simple enough to be understood
by a highschool student and his father :) .
 
B

beliavsky

When I have a Python script generating a lot of output, I either open
an output file and then print to it with

fp = open("results.txt","w")
print>>fp,"stuff"

or I redirect output to a file from the command line using ">" (also
works on Unix), for example

python foo.py > results.txt

An alternative is to open a shell buffer within Emacs or XEmacs, two
text editors with Python modes. You can run a Python script from within
the shell buffer, and the results will be printed there. You can move
around the shell buffer as if it were a file.
 
P

Paul Rubin

Gavin Bauer said:
Thank you, and please make all answers simple enough to be understood
by a highschool student and his father :) .

You might like to try IDLE, which is included with Python.
 
S

Steve Holden

Gavin said:
My DOS window (running in windows ME) closes the second it finishes
running my programs. As you can imagine, this makes it hard to see the
results. I've gotten in the habit of putting raw_input("Press enter to
exit") at the end of every program, and in addition to being pain in
the butt, it often fails to work. Being new to programming in general,
I make more mistakes than most people. My programs often have errors
before they get to my raw_input command. They then display the error
and immediately close. It is naturally a lot easier to fix an error
when you know what the error is. This makes debugging even more
annoying than it ordinarily would be, if you can imagine that. I've
heard that it should be a simple preference fix, but I've asked around
and no one seems to know how.
I presume this means you are starting the program by the time-honored
expedient of double-clicking on it. For debugging you would probably
find it more satisfactory to run your programs from the command line,
and there's a FAQ that explains how at

http://www.python.org/doc/faq/windows.html

If that isn't simple enough then please let me know, as it's *supposed*
to be.
Thank you, and please make all answers simple enough to be understood
by a highschool student and his father :) .

If you wanted to get really adventurous you could try tweaking the
command that Windows runs when you double-click a Python script, but
we'll leave that for another time.

Welcome to Python!

regards
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top