Skip to main content

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.

Release files for sigmaepsilon.deepdict 3.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sigmaepsilon.deepdict 3.0.1
File Size Uploaded
sigmaepsilon_deepdict-3.0.1.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sigmaepsilon.deepdict 3.0.1
File Interpreter ABI Platform
sigmaepsilon_deepdict-3.0.1-py3-none-any.whl Python 3 none any Details

Total release size:22.8 kB

Release files / sigmaepsilon_deepdict-3.0.1.tar.gz

Download URL sigmaepsilon_deepdict-3.0.1.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8482edc98557cae3a37e762c22372003c21d6241f1a87da33909c45ed22ffdee
BLAKE2b-256 checksum
How to use checksums
ae9f4718923bdf12b232f52e714f8f3ee8d407da7617b87c69936aeb1d18ba2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.12.8 Linux/6.8.0-1018-aws

Release files / sigmaepsilon_deepdict-3.0.1-py3-none-any.whl

Download URL sigmaepsilon_deepdict-3.0.1-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d900af629484decafd8d34d81d47731680c78d9b0f3a26adc1bcd56184b99f32
BLAKE2b-256 checksum
How to use checksums
c4e22e07128b37dda6dca47b84cb25cc1b59fe5a3901983ae48ca780aea6ae5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.12.8 Linux/6.8.0-1018-aws

Release history Release notifications | RSS feed

This release

3.0.1 This release

2 release files

3.0.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.2.4

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page