Name
__getattribute__ — Python 2.2 and later
Synopsis
__getattribute__(self,name)At every request to access attribute
x.y,
if x is an instance of new-style class
C, Python calls
x
.__getattribute__('y'), which
must obtain and return the attribute value or else raise
AttributeError. The normal semantics of attribute
access (using x
.__dict__, C
.__slots__, C’s class
attributes, x
.__getattr__) are all due to object.__getattribute__.
If class C overrides __getattribute__, it must implement all of the attribute
access semantics it wants to offer. Most often, the most convenient
way to implement attribute access semantics is by delegating (e.g.,
calling object.__getattribute__(self,
...) as part of the operation of your override of
__getattribute__). Note that a class that
overrides __getattribute__ makes attribute
access on instances of the class quite slow, since your overriding
code is called on every such attribute access.