When something goes wrong at run time, Python raises an exception: an object describing the error, with a type (its class) and usually a message. Exceptions are organised into a class hierarchy, a family tree in which more specific exception types inherit from more general ones. This matters because an except clause that names a class also catches every class below it in the tree. Knowing the tree lets you predict which handler runs, and lets you choose how broad or narrow each handler should be.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 7 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.