class A:
def __init__(self, name):
self.name = name def __get__(self, ins, cls):
print('call get')
if ins is None:
return self
return ins.__dict__[self.name] def __set__(self, ins, val):
print('call set')
ins.__dict__[self.name] = val def __delete__(self, ins):
print('cal del')
del ins.__dict__[self.name] class B:
a1 = A('a1') def __init__(self):
self.a1 = 3 #b=B.__new__(B)
b=B()
b.a1
#B.a1

  

05-11 20:45