Consider a Python object o
of class C
. What exactly happens when accessing o.foo
?
Presumably the runtime first looks to see whether o
itself contains foo
(in its __dict__
and/or __slots__
), then checks C
, then the base classes of C
.
Is that fundamentally how attribute lookup is performed? If so, presumably the process is more complicated in practice - are other locations checked for foo
?
Are there facilities in Python that can be used to customize the above lookup process?