8 lines
261 B
Python
8 lines
261 B
Python
|
class AttrDict(dict):
|
||
|
def __getattr__(self, key):
|
||
|
if key in self:
|
||
|
return self[key]
|
||
|
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{key}'")
|
||
|
|
||
|
def __setattr__(self, key, value):
|
||
|
self[key] = value
|