how do I exit gracefully?

Andrew Pierce NospaMapierce at escapeNospaM.com
Sat Oct 28 19:27:38 EDT 2000


Sorry if this is a banal question, but how to I gracefully exit a python
program instead of the 'normal' method of running out of lines of code to
execute?  I dug around the FAQ and DejaNews and found sys.exit() and
os._exit() but both of these methods raise exceptions.  What happens when a
python program terminates normally by running out of code, that is, when
python runs out of executable statements does it raise an exception (it
doesn't seem to near as I can tell)?  Is there a way for me to cause this
same procedure (whatever it is) to happen early?  I have a number of checks
that need to pass for a cgi-script and if any of them fail I'd like a
graceful (and preferably silent) way to end the script.  Thanks for any
help.
     -Andy Pierce





More information about the Python-list mailing list