You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
445 B
19 lines
445 B
class DictThing:
|
|
def __init__(self, init_dict):
|
|
self.d = init_dict
|
|
|
|
def __setattr__(self, name, value):
|
|
if name == "d":
|
|
super().__setattr__("d", value)
|
|
else:
|
|
|
|
self.d[name] = value
|
|
|
|
def __getattr__(self, name):
|
|
if name == "d":
|
|
return super().__getattribute__("d")
|
|
return self.d[name]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
e = DictThing(dict(a="a", b="b", c="c"))
|