Be able to initialize with a flattened dict?
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.
Here is the algorithm I used to unflatten a dict https://stackoverflow.com/a/55545369/7391331
If this is added, I think it would be good to also have a method to pack in into a flattened dict.
Adding this feature in Box 7! Please test and give feedback if possible pip install python-box[all]~=7.0.0rc0
Specifically will require combo of default_box and box_dots, or which is same as using new DDBox class
Added in 7.0.0