New-style classes give you more ways to control what happens when an instance's attribute is accessed.
Here is the general procedure for access to attribute
of
instance a,
where i is
the class of C.
i
If the instance has a __getattribute__() special method (see
Section 26.3.15, “__getattribute__(): Intercept all
attribute references”), execute
that method, which must either return the attribute
value or raise AttributeError.
If the instance has a __slots__
attribute (see Section 26.2.4, “Conserving memory with __slots__”),
return the value of the slot with name . If a does not
match any of the slot names, or if the named slot
has never been set to a value, raise aAttributeError.
If is
a key in ai.__dict__, return the
corresponding value.
Search for attribute in class a. If that
fails, search all the parent classes of C all the
way back to Cobject.
If all searches in the preceding step failed and
the instance has a .__getattr__()
special method, call that method. See Section 26.3.14, “__getattr__(): Handle a reference
to an unknown attribute”; please note the
differences from Section 26.3.15, “__getattribute__(): Intercept all
attribute references”.
If all the above steps fail to produce a value,
raise AttributeError.