Exception Attributes

BaseException.__notes__ — exception attribute

Read the list of notes attached through add_note(). The attribute need not exist on a new exception, so use getattr(error, "__notes__", []) when inspecting an unfamiliar instance. Notes are separate from args and are intended for diagnostic context.

Formal Syntax & Structure

python syntaxpython
error.__notes__

Return Value

list[str] (when present)

Notes in insertion order; absent before initialization.

Working Example

Example Snippetpython
error = ValueError("bad")print(hasattr(error, "__notes__"))error.add_note("row 4")error.add_note("column price")print(error.__notes__)
Python Reference