Skip to main content

Python module for interacting with nested dicts as a single level dict with delimited keys.

Project description

FlatDict

Version Status Coverage License

FlatDict and FlatterDict are dict classes that allow 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flatdict-4.1.0.tar.gz (33.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flatdict-4.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file flatdict-4.1.0.tar.gz.

File metadata

  • Download URL: flatdict-4.1.0.tar.gz
  • Upload date:
  • Size: 33.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flatdict-4.1.0.tar.gz
Algorithm Hash digest
SHA256 63bcd906a0859d91d0aace44b327178706c7fcf85a88c7ccf0825628376ad66b
MD5 5255ffbc576f60b525399999eccef772
BLAKE2b-256 1fbae0461697020839f60741e493fc42b20a4cd3f91594ed3228f65ae9a50aee

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatdict-4.1.0.tar.gz:

Publisher: deploy.yaml on gmr/flatdict

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flatdict-4.1.0-py3-none-any.whl.

File metadata

  • Download URL: flatdict-4.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flatdict-4.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24c3ff816733e472f91071031bd286c3826ecf2d646d5020af49fe10b20a5677
MD5 c6fe1f61eb1a9ebbb9b024a6f9b06224
BLAKE2b-256 12b56b6c496304047982b67d984ed2f77c183f73d69f7dbbc0cd2928252cc6b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatdict-4.1.0-py3-none-any.whl:

Publisher: deploy.yaml on gmr/flatdict

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page