How to exit early?

François Pinard pinard at
Mon Aug 12 18:57:50 CEST 2002

[brobbins333 at]

> I want to [...] exit without running the remainder of the script.
> What's the best way to do this?

Suppose you want to exit with status code 13.  You may use either:

    raise SystemExit, 13

or maybe:

    import sys

If you want status 0, representing no error, you may prefer to write
either of:

    raise SystemExit

    import sys

François Pinard

More information about the Python-list mailing list