Skip to main content

Dotty dict-like object allow to access deeply nested keys using dot notation.

Project description

Info:

Dictionary wrapper for quick access to deeply nested keys.

Author:

Paweł Zadrożny @pawelzny <pawel.zny@gmail.com>

CI Status Documentation Status PyPI Repository Status Release Status Project Status Supported python versions Supported interpreters License

Features

  • Simple wrapper around python dictionary and dict like objects

  • Two wrappers with the same dict are considered equal

  • Access to deeply nested keys with dot notation: dot['deeply.nested.key']

  • Create, read, update and delete nested keys of any length

  • Expose all dictionary methods like .get, .pop, .keys and other

Installation

pipenv install dotty-dict  # or pip install dotty-dict

Documentation

TODO

  • key=value caching to speed up lookups and low down memory consumption

Quick Example

Create new dotty using factory function.

>>> from dotty_dict import dotty
>>> dot = dotty({'plain': {'old': {'python': 'dictionary'}}})
>>> dot['plain.old']
{'python': 'dictionary'}

You can start with empty dotty

>>> from dotty_dict import dotty
>>> dot = dotty()
>>> dot['very.deeply.nested.thing'] = 'spam'
>>> dot
Dotty(dictionary={'very': {'deeply': {'nested': {'thing': 'spam'}}}}, separator='.', esc_char='\\')

>>> dot['very.deeply.spam'] = 'indeed'
>>> dot
Dotty(dictionary={'very': {'deeply': {'nested': {'thing': 'spam'}, 'spam': 'indeed'}}}, separator='.', esc_char='\\')

>>> del dot['very.deeply.nested']
>>> dot
Dotty(dictionary={'very': {'deeply': {'spam': 'indeed'}}}, separator='.', esc_char='\\')

>>> dot.get('very.not_existing.key')
None

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

dotty_dict-1.0.0.tar.gz (32.7 kB view details)

Uploaded Source

File details

Details for the file dotty_dict-1.0.0.tar.gz.

File metadata

  • Download URL: dotty_dict-1.0.0.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dotty_dict-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1d3f33fb718d453ec51c59154b46ad294393a000b221e6b16282ec9c7cd44de7
MD5 2e0f680a8ed29842721802c676704de2
BLAKE2b-256 cf912e85f8db91e363e5b05fbfc3a2caa064ec096f5cce50f4498c98b117e516

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