ndict-tools
In standard Python, dictionaries within dictionaries are possible, creating nested data structures. However, while this functionality exists, Python does not offer native features to easily search and manage keys and values within complex nested dictionaries.
My research and testing of libraries dedicated to managing nested dictionaries led me to several solutions, but none fully met my expectations. The module I found that came closest was one from 2015, available on PyPI, but it does not provide a complete architecture for managing "nested dictionary objects" in a smooth and robust way.
This motivated me to redevelop such a module, offering a more complete and intuitive way to handle nested dictionaries. This new module makes it easier to manipulate, search, and manage keys and values in complex data structures by providing tools dedicated to this specific task.
What is a Nested Dictionary?
A nested dictionary is simply a dictionary where the values themselves are dictionaries. This allows for the creation of richer, hierarchical data structures where each "node" in the structure can hold additional information in the form of dictionaries, making it easier to model complex data in an organized and accessible way.
Using Nested Keys and Managing Hierarchies in Dictionaries
Keys of Different Types and Using Lists for Hierarchical Keys
Just like with standard dictionaries in Python, the keys in a nested dictionary must be hashable. This means you can use types such as numbers, strings, or even tuples as keys. However, lists are not hashable and cannot be used directly as keys.
Accessing Nested Values
Nested dictionaries allow you to structure your data over multiple levels. For example, to access a value in a nested dictionary, you can use a sequence of keys that represents each level of the hierarchy.
Using simple, non-nested lists is the way used to represent nested keys.
Nested Access Example
The following two expressions are equivalent for accessing a value in a nested dictionary:
dictionary[[1, "a", (2, 3)]] # is equivalent to
dictionary[1]["a"][(2, 3)]
Installation
pip install ndict-tools
Documentation
Full documentation is available at ndict-tools.readthedocs.io.
Contributing
See CONTRIBUTING.md for setup instructions and contribution guidelines.
License
This project is licensed under the CeCILL-C Free Software License.
Metadata
Release files for ndict-tools 1.3.0
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 |
|---|---|---|---|---|
| ndict_tools-1.3.0.tar.gz | 307.6 kB | Without provenance | Details for ndict_tools-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ndict_tools-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for ndict_tools-1.3.0-py3-none-any.whl |
Total release size: 357.9 kB
Release files / ndict_tools-1.3.0.tar.gz
| Download URL | ndict_tools-1.3.0.tar.gz |
|---|---|
| Size | 307.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aef3655aef7e61456504e468702d8a5b2cf269f79c0dceee896efcbaa9c52f54
|
|
BLAKE2b-256 checksum How to use checksums |
2c2e600ff8535be55d8910462ed8350a4b069727637922802e53e995f14ea9f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / ndict_tools-1.3.0-py3-none-any.whl
| Download URL | ndict_tools-1.3.0-py3-none-any.whl |
|---|---|
| Size | 50.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2cebc82fe50223009c1edbef549a6729a8928b3641ec253c91e9fc14d471a043
|
|
BLAKE2b-256 checksum How to use checksums |
d49c195028c57fb73fefa203ed71ff631632089e65ec4343775f1f96c36911cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for ndict-tools 1.3.0
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.