Stopping Execution

Fredrik Lundh fredrik at
Thu Nov 10 22:45:20 CET 2005

James Colannino wrote:

> Hey everyone.  I remember from my C programming that I can either use
> the exit() or return() functions to end execution of the main code
> block.  My question is, is there a way for me to do this in Python?  I
> know there has to be, but I can't for the life of me figure out what it
> is.  The reason I ask is that I need to conditionally end a script I'm
> writing at various places.  Thanks in advance.

the usual way:

    sys.exit() # or "raise SystemExit"

hard exit, for special cases:



More information about the Python-list mailing list