program termination and return value

F. Petitjean littlejohn.75 at
Fri Oct 8 22:33:43 CEST 2004

On 8 Oct 2004 13:20:51 -0700, Scott Carlson <scarlson at> 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

   on the python prompt :
   import atexit

   good reading!

More information about the Python-list mailing list