By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,100 Members | 2,892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,100 IT Pros & Developers. It's quick & easy.

DOS problem (simple fix??)

P: n/a
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 :) .
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.

Jul 18 '05 #2

P: n/a
Gavin Bauer <gm*******@gmail.com> writes:
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.
Jul 18 '05 #3

P: n/a
Gavin Bauer wrote:
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
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.