Skip to main content

← All terms Β· Errors & control flow

Exception

An object that signals something went wrong. Raised with `raise`, caught with `try/except`.

Learn this interactively:

Open lesson lesson-100 β†’

Related β€” Errors & control flow

try / except / finallyHandle exceptions. `finally` always runs (cleanup). Catching `Exception` is usua…Context managerAn object usable with `with`. Guarantees cleanup even on exception β€” `open()`, l…EAFPβ€œEasier to Ask Forgiveness than Permission”. Idiomatic Python: try the operation…