Skip to main content

A Python library designed for deep-merging, updating, and compressing dictionaries.

Project description

dictpress

Simple dictionary manipulation utilities for Python.

Installation

pip install dictpress

Usage

from dictpress import flatten_dict, unflatten_dict, merge

# Flatten nested dictionaries
data = {"a": {"b": {"c": 1}}, "x": 2}
flattened = flatten_dict(data)
# {"a.b.c": 1, "x": 2}

# Unflatten back to nested structure
nested = unflatten_dict(flattened)
# {"a": {"b": {"c": 1}}, "x": 2}

# Deep merge dictionaries
base = {"a": {"b": 1}, "c": 2}
update = {"a": {"d": 3}, "e": 4}
merged = merge(base, update)
# {"a": {"b": 1, "d": 3}, "c": 2, "e": 4}

API

flatten_dict(data: dict) -> dict

Flatten nested dictionary into single-level with dot notation keys.

unflatten_dict(data: dict) -> dict

Convert flattened dictionary back to nested structure.

merge(data: dict, update: dict) -> dict

Deep merge two dictionaries. Values from update take precedence.

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

dictpress-0.1.0.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

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

dictpress-0.1.0-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dictpress-0.1.0.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Darwin/24.5.0

File hashes

Hashes for dictpress-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b4d15ced31cddbe1b38eb4343509db32f4bae26da65e2a8d803d9a1e532e111b
MD5 934863066aa2d966e7a39a5f13ad5acd
BLAKE2b-256 bd742bf4eda0a0526c5a305e1458564909fec621c15cd9eb6d25c4b80e2a20b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dictpress-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Darwin/24.5.0

File hashes

Hashes for dictpress-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58eb029861437d5d9d8eee3c36734ce3a571d9a6748755013eee3e8075dfe8f0
MD5 4b13d7d26428691fa77ee734ec127e2d
BLAKE2b-256 5cb09b8f8cb1f409e247c4d653657dc3dfa67131c2e2f850ad3b840ab7eb9a8b

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