mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-22 17:12:55 +08:00
25 lines
331 B
Python
25 lines
331 B
Python
|
|
_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')
|