program termination and return value
F. Petitjean
littlejohn.75 at noos.fr
Fri Oct 8 16:33:43 EDT 2004
On 8 Oct 2004 13:20:51 -0700, Scott Carlson <scarlson at omnimn.com> wrote:
> Hi,
>
> Python novice. (But getting better.)
>
> How do I terminate/quit my program during execution if I reach a point
> where I desire to terminate the program?
raise SystemExit
>
> How do I pass back an integer indicating (as example) an error number?
raise SystemExit(2) # error number 2
>
> If I then do this, what do I put on the last line of my program to
> return (for example) a zero, indicating success?
noting : an equivalent to sys.exit(0) or raise SystemExit(0) is
automatically generated.
>
> Thanks,
> Scott
You can also use :
import sys
sys.exit(0)
on the python prompt :
import atexit
help(atexit)
good reading!
More information about the Python-list
mailing list