Program termination: Difference between revisions
Content added Content deleted
(→{{header|Python}}: Add subheadings/emphasis) |
|||
Line 482: | Line 482: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
;Polite: |
|||
<lang python>import sys |
<lang python>import sys |
||
if problem: |
if problem: |
||
sys.exit(1)</lang> |
sys.exit(1)</lang> |
||
The [http://docs.python.org/library/atexit.html atexit] module allows you to register functions to be run when the program exits. |
The [http://docs.python.org/library/atexit.html atexit] module allows you to register functions to be run when the program exits. |
||
;As soon as possible: |
|||
No cleanup is performed: |
|||
(Signals the underlying OS to abort the program. No cleanup is performed) |
|||
<lang python>import os |
<lang python>import os |
||
if problem: |
if problem: |