Skip to main content

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


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)

Uploaded Source

Built Distribution

pyresolve-1.1.0-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page