Next / Previous / Contents / Shipman's homepage

25.3. Built-in exceptions

Python defines a complete hierarchy of built-in exception classes. When you write a handler, you can specify any class in this hierarchy, and that handler will apply to that class and any derived classes. This allows you to write generic handlers that catch whole groups of exception types.

In describing this hierarchy, we will use indentation to show the subclass/parent class relationships. Generally a raise statement will name one of the “leaf” classes, that is, a class that does not have any subclasses. Ancestor classes that are not usually raised are marked with an asterisk (*) in the section below.