Skip to main content

Dict class with dot notation (like attributes) for accessing nested values

Project description

Build Status Coverage Status

DotAccessDict

DotAccessDict class can handle nested dictionaries with arbitray number of dicts and lists, nested inside each other.

Usage:

>>> from ddict import DotAccessDict
>>> d = DotAccessDict()
>>> d
{}
>>> d.person
{}
>>> d.person.name = 'Jack'
>>> d
{'person': {'name': 'Jack'}}
>>> d['person']['name']
'Jack'
>>> d['person'].name
'Jack'
>>> d.person['name']
'Jack'
>>> joe = dict(name='Joe', age=18)
>>> d.person.brothers = [joe, 'John', 'Pat']
>>> d.person.brothers[0].age
18
>>> d.get('person.brothers[1]')
'John'
>>> d.set('person.brothers[2]', 'James')
>>> d.person.brothers[2]
'James'
>>> d.flatten()
{'person.brothers[0].age': 18,
 'person.brothers[0].name': 'Joe',
 'person.brothers[1]': 'John',
 'person.brothers[2]': 'James',
 'person.name': 'Jack'}

Similar works:

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

ddict-0.1.3.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file ddict-0.1.3.tar.gz.

File metadata

  • Download URL: ddict-0.1.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ddict-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8a3382eb0c74e92c75c5b59d6e2ebe79225a36e5798afb9f661ae60e1f6e4168
MD5 1eda02857cc6ba545b1010cdd1f6a500
BLAKE2b-256 29363874b2d5be3670ff4e9a9755412b0b5e3252ab26c889c392555c63b98680

See more details on using hashes here.

Supported by

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