Loading topic
if, for, and while, and read a simple traceback. It covers the basic try/except statement. Handler ordering, else, and finally come in later chapters.2 min readif/for/while control flow, read a simple traceback, and define a class that inherits from another. It also assumes you know the basic try/except form from the previous chapter.3 min readtry/except statement and know that exception classes form a hierarchy, with Exception near the top and ValueError below it. You should also be able to read a simple traceback.2 min readtry/except statement and know that exceptions are objects created from classes. Here you will learn how to get at the exception object that Python raised, and what you can safely do with it.2 min readtry and except with specific exception types. It covers the else clause of a try statement, which holds code that should run only when the try block raised nothing.2 min readtry and except, and read a basic traceback. It covers what finally guarantees, how it behaves on each exit path, and the mistakes that make it dangerous.2 min readtry/except/finally statements and know how exceptions propagate. It covers what happens when control leaves a try block early, and why you should not leave a finally block early.2 min readtry and except, and read a simple traceback. You have been catching exceptions so far. Here you will start signalling them yourself.2 min readtry/except blocks, bind an exception with as, and read a basic traceback. It covers how to record an error or clean up after it without hiding it from the caller.2 min readtry/except blocks, raise exceptions with raise, and define a simple exception class. It covers how to keep the original error attached when you raise a new one.2 min readtry/except blocks, know that exceptions form a class hierarchy under BaseException and Exception, and can write a basic subclass.2 min readtry/except/finally, define functions and classes, and read a simple traceback. It shows how the with statement packages the cleanup pattern from the finally chapter so you don't have to repeat it.2 min readtry/except/else/finally statements, know the built-in exception hierarchy, and have defined a simple custom exception class. It collects the habits that keep error handling reliable.2 min readtry/except, how handlers are matched against the exception hierarchy, and how raise works. It also needs Python 3.11 or later.2 min read