I'm in a situation where I need to deal with some deeply nested structures, but I want to initialize them with dictionaries of dotted keys. So I'd ideally like to be able to do something like:
d = Box({'service.name': 'django', 'service.version': 2.2})
print(d.service.name)
# Prints 'django'
print(d.service.keys())
# prints "dict_keys(['name', 'version'])"
print(d.to_dict())
# prints {'service': {'name': 'django', 'version': 2.2}}
Now, I can do this if I initialize the Box, then write to it as d.service.name = 'django', but it'd be nice to be able to unflatten the incoming dict somehow.
I'm in a situation where I need to deal with some deeply nested structures, but I want to initialize them with dictionaries of dotted keys. So I'd ideally like to be able to do something like:
Now, I can do this if I initialize the Box, then write to it as d.service.name = 'django', but it'd be nice to be able to unflatten the incoming dict somehow.