PDA

View Full Version : How do I keep Python program open?



swoll1980
June 18th, 2009, 12:07 AM
When I run a Python program outside of the interpreter, it runs through the program, and closes before I can read the output. How do I stop this. Thanks.

simeon87
June 18th, 2009, 12:09 AM
Does it print to the terminal? If so, you could open a terminal and then run the program from the terminal. It'll then display the output in the terminal, which doesn't close after the program is finished.

swoll1980
June 18th, 2009, 12:13 AM
Does it print to the terminal? If so, you could open a terminal and then run the program from the terminal. It'll then display the output in the terminal, which doesn't close after the program is finished.

Yeah it prints to the terminal. Thanks for the tip. Have a great day!

smartbei
June 18th, 2009, 08:06 PM
Alternately, you could stick:


raw_input("This is here just so the program doesn't close on me!! :-)")

At the end, and it will make the program wait for your Enter until it closes.

swoll1980
June 20th, 2009, 05:44 AM
Alternately, you could stick:


raw_input("This is here just so the program doesn't close on me!! :-)")

At the end, and it will make the program wait for your Enter until it closes.

Good Idea.

Eisenwinter
June 20th, 2009, 10:06 AM
Keep a while loop going on "True".

while True:
if condition: print data

pokerbirch
June 20th, 2009, 02:20 PM
Ewwww, yuk! An infinite loop is NOT the way to solve this simple problem. As suggested above, run your script via the terminal. It's the correct way to do things.