11 lines
330 B
Python
11 lines
330 B
Python
from types import SimpleNamespace
|
|
|
|
|
|
class NestedNamespace(SimpleNamespace):
|
|
def __init__(self, dictionary, **kwargs):
|
|
super().__init__(**kwargs)
|
|
for key, value in dictionary.items():
|
|
if isinstance(value, dict):
|
|
self.__setattr__(key, NestedNamespace(value))
|
|
else:
|
|
self.__setattr__(key, value)
|