Skip to main content

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

Project description

Version Build 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:

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 flatdict2

Or using Poetry:

$ poetry add flatdict2

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

flatdict3-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

flatdict3-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file flatdict3-0.1.0.tar.gz.

File metadata

  • Download URL: flatdict3-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.11 Linux/6.16.12-200.fc42.x86_64

File hashes

Hashes for flatdict3-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8882f1af8f3702cdfce0588fa2638734a736d4d7c5d6e84e3c17d54224d03295
MD5 4075eb9d7662f3d6aa372da78849f9b6
BLAKE2b-256 37678b6f1158edcd9780e89a6375e24f9ea4b29625bef55c19acd6cd06f32ce6

See more details on using hashes here.

File details

Details for the file flatdict3-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: flatdict3-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.11 Linux/6.16.12-200.fc42.x86_64

File hashes

Hashes for flatdict3-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b3ac2f1e8f57fafc020c0051539ac4f698c6f93f675050482c85a813df35734
MD5 a4fa3a4563b0d49de1c7258e7c883884
BLAKE2b-256 f8702f43005eeebf121b28814bf530fc332ddb921765ce368891d28f517b5457

See more details on using hashes here.

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