4 ms·
These days (Python >= 3.3) SimpleNamespace is a more concise way of doing this: from types import SimpleNamespace d = SimpleNamespace(a=1, b=2) print
by theptip 10y ago
These days (Python >= 3.3) SimpleNamespace is a more concise way of doing this:
from types import SimpleNamespace
d = SimpleNamespace(a=1, b=2)
print(d.a)
- gshulegaard 10y agoHaha neat, that means this works very cleanly as a conversion mechanism: my_dict = { 'a': 1, 'b': 2 } d = SimpleNamespace(**my_dict) print(d.a)