Skip to content

Handle and Trace Python Exceptions

Step 11 of 41

Propagation, Cleanup, and Assertions

Introduction

This lesson completes objective 2.1 of PCAP-31-03. The previous lesson showed how Python chooses an except clause. Here you learn what happens when no clause in the current function matches, how finally guarantees cleanup, how to raise exceptions yourself with raise, and how assert checks assumptions. The material belongs to the Exceptions section: 14% of the score and 5 of the 40 items. Tracing questions on this topic are common because a few lines of code can hide a surprising order of output.