Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gmr/flatdict
Python module for interacting with nested dicts as a single level dict with delimited keys.
https://github.com/gmr/flatdict
dict hacktoberfest python python3
Last synced: 3 days ago
JSON representation
Python module for interacting with nested dicts as a single level dict with delimited keys.
- Host: GitHub
- URL: https://github.com/gmr/flatdict
- Owner: gmr
- License: bsd-3-clause
- Created: 2012-08-10T23:55:12.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-11-14T18:03:53.000Z (about 1 year ago)
- Last Synced: 2024-05-02T00:02:42.181Z (9 months ago)
- Topics: dict, hacktoberfest, python, python3
- Language: Python
- Homepage: https://flatdict.readthedocs.io
- Size: 193 KB
- Stars: 109
- Watchers: 5
- Forks: 31
- Open Issues: 16
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
FlatDict
========|Version| |Status| |Coverage| |License|
``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:*
.. code-block:: python
value = flatdict.FlatDict({'foo': {'bar': 'baz', 'qux': 'corge'}})
*would be the same as:*
.. code-block:: python
value == {'foo:bar': 'baz', 'foo:qux': 'corge'}
*values can be accessed as:*
.. code-block:: python
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:*
.. code-block:: python
value = flatdict.FlatterDict({'list': ['a', 'b', 'c']})
*will be the same as:*
.. code-block:: python
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
------------.. code-block:: bash
$ pip install flatdict
Note that as of 4.0, setuptools 39.2 or higher is required for installation.
.. |Version| image:: https://img.shields.io/pypi/v/flatdict.svg?
:target: https://pypi.python.org/pypi/flatdict.. |Status| image:: https://github.com/gmr/flatdict/workflows/Testing/badge.svg
:target: https://github.com/gmr/flatdict/actions
:alt: Build Status.. |Coverage| image:: https://img.shields.io/codecov/c/github/gmr/flatdict.svg?
:target: https://codecov.io/github/gmr/flatdict?branch=master.. |License| image:: https://img.shields.io/pypi/l/flatdict.svg?
:target: https://flatdict.readthedocs.org