我试图重写getattr方法,据我理解,下面的代码段中应该有无限循环,因为默认情况下调用object.__getattribute__(self,attr),它将调用过高的getattr方法,因为名称空间中不存在属性'notpresent‘,这个过程将继续重复。此外,当我们试图在方法中显式调用getattribute时,当使用点表示法访问属性时,当执行对getattribute的隐式调用时,我无法理解为什么不引发AttributeError。object):
#Act as a fallback and
如果我有下面的类: class Item: return super().__getattribute__(a) print ("Calling the second one (AttributeErroron __getattribute__)!")现在,如果我这样做: i=Item()
i.x 它将命中__getattribute_