Built-in Exceptions
AttributeError — exception class
Raised when an attribute cannot be accessed or assigned, including errors explicitly raised by attribute hooks. getattr(obj, name, default) supplies a fallback on AttributeError; beware of masking errors inside properties. name and obj can identify the failed lookup. Catch AttributeError when this category is the recovery boundary; do not rely on the exact human-readable message.
Formal Syntax & Structure
python syntaxpython
AttributeErrorReturn Value
type
The class object AttributeError; this reference documents the class identity, not a universal constructor signature.
Working Example
Example Snippetpython
item=object()try: getattr(item, "missing")except AttributeError as error: print(type(error).__name__)