__getattribute__

class Foo:
    def __init__(self,x):
        self.x = x
    def __getattribute__(self, item):
        print('不管是否纯在,我都会执行')

f1 = Foo(10)
f1.x
f1.xxxxxxxxxxx

  

原文地址:https://www.cnblogs.com/huangjinshan/p/6224931.html