Skip to main content

Common developer utilities for Python projects.

Project description

SigmaEpsilon.DeepDict - A lightweight Python library for nested dictionaries

CircleCI codecov Codacy Badge Documentation Status License PyPI - Downloads PyPI - Version PyPI - Python Version Code style: black Static Badge

sigmaepsilon.deepdict is a lightweight Python library designed to handle nested dictionaries more easily, especially in cases where dictionaries are created dynamically. Its key feature is the DeepDict class, which extends the regular dict to support nested layouts. It allows easy manipulation of deeply nested structures, array-like indexing, and automatic creation of deep dictionary levels without manually defining all parent keys. It is particularly useful in scenarios involving hierarchical data. The library also supports printing dictionaries as trees.

The first implementation of the DeepDict class was based on this StackOverflow thread.

Key Features

  • Nested Layout Support: DeepDict allows for seamless manipulation of deeply nested structures, enabling array-like indexing and automatic creation of nested dictionary levels without the need to manually define all parent keys.

  • Parent-Child Awareness: Each sub-dictionary within a DeepDict is aware of its parent container, providing attributes like key, address, and parent.key to facilitate navigation and management of the nested structure.

  • Tree Representation: With the optional installation of the asciitree library, DeepDict can print dictionaries as trees, offering a visual representation of the nested data.

Example Usage

from sigmaepsilon.deepdict import DeepDict

# Creating a DeepDict instance
data = DeepDict()
data["a", 0, "b", 1, 5] = 10

# Accessing attributes
print(data["a", 0, "b"].key)       # Output: 'b'
print(data["a", 0, "b"].address)   # Output: ['a', 0, 'b']
print(data["a", 0, "b"].parent.key) # Output: 0

See the documentation for more examples and explanation on behaviour.

Documentation

The documentation is built with Sphinx using the PyData Sphinx Theme and hosted on ReadTheDocs.

Installation

For installation instructions, please refer to the documentation.

License

This package is licensed under the MIT license.

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

sigmaepsilon_deepdict-3.0.1.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

sigmaepsilon_deepdict-3.0.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file sigmaepsilon_deepdict-3.0.1.tar.gz.

File metadata

  • Download URL: sigmaepsilon_deepdict-3.0.1.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.8 Linux/6.8.0-1018-aws

File hashes

Hashes for sigmaepsilon_deepdict-3.0.1.tar.gz
Algorithm Hash digest
SHA256 8482edc98557cae3a37e762c22372003c21d6241f1a87da33909c45ed22ffdee
MD5 a22abbab3546b502ac137fe70621b869
BLAKE2b-256 ae9f4718923bdf12b232f52e714f8f3ee8d407da7617b87c69936aeb1d18ba2a

See more details on using hashes here.

File details

Details for the file sigmaepsilon_deepdict-3.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sigmaepsilon_deepdict-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d900af629484decafd8d34d81d47731680c78d9b0f3a26adc1bcd56184b99f32
MD5 fc848ad0d3bcdcfe9b3bf3771bcbe696
BLAKE2b-256 c4e22e07128b37dda6dca47b84cb25cc1b59fe5a3901983ae48ca780aea6ae5e

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