class C(object): a = 'abc' def __getattribute__(self, *args, **kwargs): print("__getattribute__() is called") return object.__getattribute__(self, *args, **kwargs) def __getattr__(self, name): print("__getattr__() is called ") return name + " from getattr" def __get__(self, instance, owner): print("__get__() is called", instance, owner) return self def foo(self, x): print(x)
>>> x=C() >>> x.a __getattribute__() is called 'abc' >>> x.b __getattribute__() is called __getattr__() is called 'b from getattr' If call an attribute which does exist ,__getattribute__() is called If call an attribute which does not exist ,__getattribute__() is called and then __getattr__() is called ? when the __get__ method will be called?no chance for my example? -- https://mail.python.org/mailman/listinfo/python-list