- Info:
Dictionary wrapper for quick access to deeply nested keys.
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
Access dicts in lists by index dot['parents.0.first_name']
key=value caching to speed up lookups and low down memory consumption
support for setting value in multidimensional lists
support for accessing lists with slices
Installation
pip install dotty-dict
Documentation
Full documentation: http://dotty-dict.readthedocs.io
Public API: http://dotty-dict.readthedocs.io/en/latest/api.html
Examples and usage ideas: http://dotty-dict.readthedocs.io/en/latest/examples.html
TODO
Waiting for your feature requests ;)
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
NOTE: Using integer in dictionary keys will be treated as embedded list index.
Install for development
Install dev dependencies
$ make install
Testing
$ make test
Or full tests with TOX:
$ make test-all
Limitations
In some very rare cases dotty may not work properly.
When nested dictionary has two keys of different type, but with the same value. In that case dotty will return dict or list under random key with passed value.
Keys in dictionary may not contain dots. If you need to use dots, please specify dotty with custom separator.
Nested keys may not be bool type. Bool type keys are only supported when calling keys with type defined value (e.g. dot[True], dot[False]).
Metadata
Release files for dotty-dict 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dotty_dict-1.3.1.tar.gz | 7.7 kB | Without provenance | Details for dotty_dict-1.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dotty_dict-1.3.1-py3-none-any.whl | Python 3 | none | any | Details for dotty_dict-1.3.1-py3-none-any.whl |
Total release size: 14.7 kB
Release files / dotty_dict-1.3.1.tar.gz
| Download URL | dotty_dict-1.3.1.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b016e03b8ae265539757a53eba24b9bfda506fb94fbce0bee843c6f05541a15
|
|
BLAKE2b-256 checksum How to use checksums |
6aab88d67f02024700b48cd8232579ad1316aa9df2272c63049c27cc094229d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.8.10 Linux/5.10.60.1-microsoft-standard-WSL2
|
Release files / dotty_dict-1.3.1-py3-none-any.whl
| Download URL | dotty_dict-1.3.1-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5022d234d9922f13aa711b4950372a06a6d64cb6d6db9ba43d0ba133ebfce31f
|
|
BLAKE2b-256 checksum How to use checksums |
1a91e0d457ee03ec33d79ee2cd8d212debb1bc21dfb99728ae35efdb5832dc22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.8.10 Linux/5.10.60.1-microsoft-standard-WSL2
|
Security for dotty-dict 1.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.