how to stop python...

Tim Peters tim.peters at gmail.com
Mon Jul 3 00:32:08 EDT 2006


[bruce]
> perl has the concept of "die". does python have anything similar. how can a
> python app be stopped?
>
> the docs refer to a sys.stop.

Python docs?  Doubt it ;-)

> but i can't find anything else... am i missing something...

>>> import sys
>>> print sys.exit.__doc__
exit([status])

Exit the interpreter by raising SystemExit(status).
If the status is omitted or None, it defaults to zero (i.e., success).
If the status is numeric, it will be used as the system exit status.
If it is another kind of object, it will be printed and the system
exit status will be one (i.e., failure).



Of course there's nothing to stop you from catching SystemExit either
-- it's just another exception, but one that happens to shut down the
interpreter in the specified way if it isn't caught & handled.



More information about the Python-list mailing list