Resolve dot notation from dictionary
from pyresolve import resolve
my_dictionary = {"out":{"middle":{"in":"Balue"}}}
# Before
my_dictionary.get('out', {}).get('middle', {}).get('in')
# After
resolve(my_dictionary, "out.middle.in") # "Balue"
Does not break for missing properties
resolve(my_dictionary, "outer.missing.something") # None
Can specify a different default value
resolve(my_dictionary, "outer.missing.something", []) # []
Supports index in list
dictionary_with_list = {"users": [{"name":"Joe"}, {"name":"Jane"}]}
resolve(my_dictionary, "users.1.name") # Jane
Supports list notation
dictionary_with_list = {"users": [{"name":"Joe"}, {"name":"Jane"}]}
resolve(my_dictionary, "users[1].name") # Jane
Install
pip install pyresolve