I would like to find an exhaustive lookup operations made by the Python interpreter when trying to access an instance attribute or setting it to a new value.
I know several things about it by reading and experimenting:
- When there is a
property
or a descriptor in the class body, it's used before anything - When there is the same attribute (with the same name I mean) in the
__dict__
of the instance and the__dict__
of the class, the instance's one is used first - When the
__gettatribute__
and the__getattr__
are both define in the class body,__gettatribute__
is used first since__getattr__
is only being called when the attribute isn't found elsewhere
But I was wondering about some limit cases... Can somebody give a explanation of all possibilities?