Built-in Exceptions

BaseException — exception class

Root of the exception hierarchy, including process-exit and interruption signals. Avoid deriving ordinary application errors directly from it; catch Exception for ordinary failures and use finally for cleanup. Broad BaseException handlers should normally re-raise control-flow signals. The example raises a controlled stand-in to demonstrate handling; it does not cause the real system failure.

Formal Syntax & Structure

python syntaxpython
BaseException

Return Value

type

The class object BaseException; this reference documents the class identity, not a universal constructor signature.

Working Example

Example Snippetpython
try:    raise KeyboardInterrupt()except BaseException as error:    print(type(error).__name__)
Python Reference