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
propertyor 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?