25 lines
331 B
Python
Raw Normal View History

2023-04-19 21:18:17 +08:00
_dict = {}
class TestProxy:
def __getattr__(self, name):
return _dict[name]
def __setattr__(self, name, value):
_dict[name] = value
test = TestProxy()
test.A = 10
assert test.A == 10
class Test:
proxy = TestProxy()
test2 = Test()
test2.proxy.B = 20
assert test2.proxy.B == 20
print('PASS')