Built-in Exceptions

Exception — exception class

Common base for ordinary built-in and application exceptions. Catching it deliberately excludes SystemExit, KeyboardInterrupt and GeneratorExit. Prefer a narrower handler where recovery depends on the reason. Catch Exception when this category is the recovery boundary; do not rely on the exact human-readable message.

Formal Syntax & Structure

python syntaxpython
Exception

Return Value

type

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

Working Example

Example Snippetpython
try:    int("bad")except Exception as error:    print(type(error).__name__)
Python Reference