Exception Attributes
AttributeError.obj — exception attribute
Inspect the object on which an attribute lookup or assignment failed. The object is retained by reference, so avoid storing exception instances indefinitely or printing sensitive object contents. Custom errors may have None for obj.
Formal Syntax & Structure
python syntaxpython
error.objReturn Value
object | None
Object associated with the failure.
Working Example
Example Snippetpython
class Record: passrecord = Record()try: record.quantityexcept AttributeError as error: print(error.obj is record) print(error.name)