1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| class Test: def __getattr__(self, item): print('__getattr__')
def __getattribute__(self, item): print('__getattribute__') return super().__getattribute__(item)
def __setattr__(self, key, value): print('__setattr__') super().__setattr__(key, value)
def __delattr__(self, item): print('__delattr__') super().__delattr__(item)
>>> test = Test() >>> test.a __getattribute__ __getattr__ >>> test.a = 1 __setattr__ >>> test.b __getattribute__ 1
|