Resolve dot notation from dictionary
Project description
pyresolve
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
Install
pip install pyresolve
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyresolve-1.1.0.tar.gz
(1.8 kB
view hashes)
Built Distribution
Close
Hashes for pyresolve-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5567469ca99ad54b4075952e5e7dd21d9d8abf92bdf6e8c0d1407a9c2f0198d8 |
|
MD5 | 45e18a6a0f5bb7538da3110b1ba290b8 |
|
BLAKE2b-256 | 7be732bc295306194793bf0346118ff01a220140b8af47b5327721ef1cdf96cc |