If I have the following class:
class Item:
def __getattribute__(self, a):
return super().__getattribute__(a)
def __getattr__(self, a):
print ("Calling the second one (AttributeError on __getattribute__)!")
Now if I do something like:
i=Item()
i.x
It will hit an AttributeError
in __getattribute__
and fall back to __getattr__
. What is the point of having such a fallback? For example, why couldn't someone just customize the __getattribute__
method itself if an AttributeError
is reached? What would be a legitimate use case of defining a __getattr__
/ __getattribute__
pair?