The Exception Model
Raising and catching a single exception: the BaseException hierarchy, the full try/except/else/finally flow, chaining, custom classes and the EAFP idiom. The core of any error-handling round.
part ofPythonoverview, primer and where to startread it →on this pageshowhide
explore
- Exception Hierarchy and Builtins4 questions
- try / except / else / finally Flow4 questions
- Exception Chaining4 questions
- Designing Custom Exceptions4 questions
- EAFP vs LBYL4 questions
- The Cost of Raising4 questions
- Attaching Notes with add_note3 questions
- Traceback Objects4 questions
questions
page 2 of 2Why does keeping caught exceptions in a list hold whole call frames alive, and what do you store instead?
level: seniorimportance: nice to knowfreq 17%
basics
~10 sAn exception references its traceback, which references every frame it passed through, which references those frames' locals. Keeping the exception keeps all of it. Store traceback.TracebackException.from_exception(exc), or the rendered text, instead.
showing 31–31 of 31