Skip to main content

Dictionary wrapper for quick access to deeply nested keys.

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

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

Install for development

Install dev dependencies

`console $ make install `

Testing

`console $ make test `

Or full tests with TOX:

`console $ make test-all `

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.1.tar.gz (35.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: dotty_dict-1.0.1.tar.gz
  • Upload date:
  • Size: 35.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for dotty_dict-1.0.1.tar.gz
Algorithm Hash digest
SHA256 aad735bc1c52c733b008357d01bd87ca0d1eead93c5fbd6c4e2a8018076c56f0
MD5 e69dc4e3ae98025d501146b4071e80d6
BLAKE2b-256 e1c7541104682d6ddbe09fe3c5458142f88a41362de66649fc5e94361e88a3d4

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