Skip to main content

Effortless nested dictionary access — dot notation, safe missing keys, auto-vivification, and more

Project description

easydotdict

Make nested dictionaries effortless — dot-notation access, safe missing-key handling, auto-vivification, deep path operations, and pretty-printing. Pure Python, no dependencies.

from easydotdict import dotdict

d = dotdict({'user': {'profile': {'name': 'Alice'}}})
print(d.user.profile.name)       # Alice
print(d['user'].profile.name)    # same
print(d.user.email)              # None (safe, no error)

d.config.database.host = 'localhost'  # auto-creates path
d.put('server.port', 8080)            # or use path string
print(d.dig('user.name'))             # Alice (deep path getter)

flat = d.flatten()                    # {'user.profile.name': 'Alice', ...}
restored = dotdict.unflatten(flat)   # reverse

d.merge({'settings': {'debug': True}})  # deep merge
print(d)                                # indented JSON

Features

  • Dot notationd.user.profile.name instead of d['user']['profile']['name']
  • Dual access — dot and bracket notation work interchangeably
  • Safe accessd.missing returns None, no KeyError/AttributeError
  • Auto-vivificationd.a.b.c = value auto-creates intermediate structures
  • Deep path operationsdig, put, has with dot-separated strings
  • Flatten / Unflatten — recursive flatten and restore with flatten() and unflatten()
  • Deep mergeupdate() and merge() merge recursively, preserving existing keys
  • Cloneclone() returns a deep independent copy
  • Empty checkis_empty() checks if the dict has no keys
  • Auto-conversion — nested dicts and lists containing dicts are wrapped automatically
  • Pretty-printprint(d) outputs indented JSON
  • to_dict() — recursively converts back to plain dicts and lists
  • Pure Python — standard library only, Python 3.8+

Install

pip install easydotdict

Documentation

See docs.md for full API reference, edge cases, and examples.

License

MIT

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

easydotdict-1.0.3.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

easydotdict-1.0.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file easydotdict-1.0.3.tar.gz.

File metadata

  • Download URL: easydotdict-1.0.3.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for easydotdict-1.0.3.tar.gz
Algorithm Hash digest
SHA256 5b41e244182a008dc1f4c129d0345a3a0ba3f5c01c03402647aef1b04d113c66
MD5 b4c4fdc1af0b777177130b8d03912269
BLAKE2b-256 d36841ee7dbb94c51e2b3c38dece758582da0c11192425949a5d54a69da0f9d0

See more details on using hashes here.

File details

Details for the file easydotdict-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: easydotdict-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for easydotdict-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 626a0c22755eace2e6101f4e15cd9a8c5fd699029d6d70879f22d74e3a7a9bc7
MD5 20e661adc8a74d5785efd4794051e379
BLAKE2b-256 0695da370a7df5f0606e6ee1e931ce347447a1f548cbc715b3c90a2aaed9ede7

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