Developer Tools Brief source

TIL: Exception.add_note

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story. The source provided limited text, so this summary is brief.

Why it matters

Python developers on 3.11+ can attach extra context to any exception that appears in the stacktrace, making production debugging faster; the impact is small but real.

Read this as

This is a short tip post by Simon Willison pointing to something Danny Roy Greenfeld shared. Python, the popular programming language, added a feature in version 3.11 called add_note, described in proposal PEP 678 by Zac Hatfield-Dodds back in 2021. It lets a programmer attach extra explanatory messages to an error, and those messages show up in the stacktrace, the report printed when a program crashes. Anyone debugging Python code can benefit.

This is a brief link post highlighting a debugging convenience in Python 3.11: the add_note method on exceptions. Engineers can attach context strings to errors that appear in stacktraces, shortening diagnosis time in production incidents. The feature has existed since 2021's PEP 678, so there is nothing new to buy, adopt or plan for. No cost, competition or risk implications are discussed in the article.

Willison's TIL post, crediting Danny Roy Greenfeld, covers BaseException.add_note(message: str), introduced in Python 3.11 per PEP 678 (Zac Hatfield-Dodds, 2021). It appends one or more note strings to any exception instance, rendered in the traceback output at runtime. The post contains no benchmarks, code examples, or discussion of limitations; it is a pointer to a tip rather than a technical deep dive.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

Python 3.11 BaseException PEP 678 add_note Ladybird Datasette

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading