: : Hello, I just started learning how to program about an hour ago and I when I make a program it just closes once its done when I run it. How can I get it to pause or something when its done?: : If you're talking about running a python script in MSWindows where the console window closes once the script is finished, then you can do something like:: : import os: os.system("pause"): : If you mean something else then you'll have to be more specific.: : : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]: : [code]: $ select * from users where clue > 0: no rows returned: [/code]: : Thanks that did the trick. Do you mind explaining how that works?

[b][red]This message was edited by Moderator at 2004-7-23 10:36:7[/red][/b][hr]: : import os: : os.system("pause"): : : Thanks that did the trick. Do you mind explaining how that works?

The os module is a way for python to interact with the operating system. The system function passes a command line to the operating system. On MSWindows, the "pause" command waits for the user to press enter (i.e. in batch files). Try passing any DOS command to os.system to see what happens.

: : Hello, I just started learning how to program about an hour ago and I when I make a program it just closes once its done when I run it. How can I get it to pause or something when its done?: : If you're talking about running a python script in MSWindows where the console window closes once the script is finished, then you can do something like:: : import os: os.system("pause"): : If you mean something else then you'll have to be more specific.: : : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]: : [code]: $ select * from users where clue > 0: no rows returned: [/code]: :

: I forgot about a pure python way of doing the same thing:: : raw_input('Press ENTER to continue...'):

Is this okay python programming, or just a simple way to get around? This is like using fgetc(stdin) in C/C++ to pause, which doesn't really make sense but is simply used for such. But of course, it doesn't make sense because its C/C++, but in python, I'd expect such stuff to not be considered bad programming...

: : I forgot about a pure python way of doing the same thing:: : : : raw_input('Press ENTER to continue...'): : : : Is this okay python programming, or just a simple way to get around? This is like using fgetc(stdin) in C/C++ to pause, which doesn't really make sense but is simply used for such. But of course, it doesn't make sense because its C/C++, but in python, I'd expect such stuff to not be considered bad programming...