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 = flatdict.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 = flatdict.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 flatdict
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
File details
Details for the file flatdict-4.0.1.tar.gz
.
File metadata
- Download URL: flatdict-4.0.1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd32f08fd31ed21eb09ebc76f06b6bd12046a24f77beb1fd0281917e47f26742 |
|
MD5 | a6730f1d70c9ebafe6da495a53b7fad6 |
|
BLAKE2b-256 | 3e0d424de6e5612f1399ff69bf86500d6a62ff0a4843979701ae97f120c7f1fe |