SystemExit

Built-in ExceptionPython 2.0+Intermediate

Raised by sys.exit(); used to exit the interpreter

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
# Triggering and catching SystemExit
try:
    raise SystemExit(0)
except SystemExit as e:
    print(f"Caught SystemExit: {e}")
    print(f"Type: {type(e).__name__}")

SystemExit is raised when raised by sys.exit(); used to exit the interpreter. Always catch specific exceptions rather than bare except clauses.

Try in Playground

Tags

exceptionerror-handlingcore