Python module for interacting with nested dicts as a single level dict with delimited keys.
Project description
FlatDict and FlatterDict are a dict classes that allows for single level, delimited key/value pair mapping of nested dictionaries. You can interact with FlatDict and FlatterDict like a normal dictionary and access child dictionaries as you normally would or with the composite key.
For example:
value = flatdict2.FlatDict({'foo': {'bar': 'baz', 'qux': 'corge'}})
would be the same as:
value == {'foo:bar': 'baz', 'foo:qux': 'corge'}
values can be accessed as:
print(foo['foo:bar'])
# or
print(foo['foo']['bar'])
Additionally, lists and tuples are also converted into dicts using enumerate(), using the FlatterDict class.
For example:
value = flatdict2.FlatterDict({'list': ['a', 'b', 'c']})
will be the same as:
value == {'list:0': 'a', 'list:1': 'b', 'list:2': 'c'}
API
Documentation is available at https://flatdict.readthedocs.io
Versioning
This package attempts to use semantic versioning. API changes are indicated by the major version, non-breaking improvements by the minor, and bug fixes in the revision.
It is recommended that you pin your targets to greater or equal to the current version and less than the next major version.
Installation
$ pip install flatdict2
Note that as of 4.0, setuptools 39.2 or higher is required for installation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flatdict2-4.0.4.tar.gz
.
File metadata
- Download URL: flatdict2-4.0.4.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75ffcdb8c80442456a43b89f343da704babe1c0eab1d01cee7c8991e521e33c0 |
|
MD5 | a7f42ae2fb83e070e60dfd7b723c39e8 |
|
BLAKE2b-256 | c4010db27dfb801d7ec1f7ad28c5f1789ad76ef3ac0ab1022c92867993aa414d |
File details
Details for the file flatdict2-4.0.4-py3-none-any.whl
.
File metadata
- Download URL: flatdict2-4.0.4-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91b2b8c749d8a179d8ddcfbb70918ea282a70324338ddb6a1fdbad32f3659874 |
|
MD5 | 18df207457d84ea4e21755854173171c |
|
BLAKE2b-256 | 8b879b574175856558a371e44529b913886b5655ea60e35896a05d3283e756c5 |