Stopping a program

Miki Tebeka miki.tebeka at zoran.com
Mon Feb 16 06:48:50 EST 2004


Hello Thomas,

> A follow up to the question posed above: I discovered sys.exit() and
> played around it. I find that it exhibits different behaviors
> depending on whether the program is run from IDLE or fron the command
> line.
sys.exit just raises SystemExit exception.
IDLE catches this exception and shows the traceback as it does to
every other exception (try `raise OSError' in IDLE).
In the command line raising SystemExit will quit the interpreter. If
you just click on the .py file from the explorer it will close after
executing the program. If you want to view what happened add
`raw_input()' just before raising SystemExit.

For most cases raising SystemExit does what you want. Just remember
the IDLE does not emulate the command prompt.

HTH.
Miki



More information about the Python-list mailing list