属性访问时拦截器
在类内部使用,对象访问属性时,getattribute()先被调用
def __getattribute__(self,obj):
xxx
可以用来做log日志文件
getattribute(self,obj)注意事项
- 禁止在这里面使用self加.的任何东西,例如,不可以self.test self.name self…等等任何东西,否则会无穷地递归调用自身__getattribute__(self,obj),如果想return 任何有关self的东西,应该把它扔给父类使用,比如return object.getattribute(self,obj)