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 notation —
d.user.profile.nameinstead ofd['user']['profile']['name'] - Dual access — dot and bracket notation work interchangeably
- Safe access —
d.missingreturnsNone, noKeyError/AttributeError - Auto-vivification —
d.a.b.c = valueauto-creates intermediate structures - Deep path operations —
dig,put,haswith dot-separated strings - Flatten / Unflatten — recursive flatten and restore with
flatten()andunflatten() - Deep merge —
update()andmerge()merge recursively, preserving existing keys - Clone —
clone()returns a deep independent copy - Empty check —
is_empty()checks if the dict has no keys - Auto-conversion — nested
dicts andlists containingdicts are wrapped automatically - Pretty-print —
print(d)outputs indented JSON to_dict()— recursively converts back to plaindicts andlists- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easydotdict-1.0.1.tar.gz.
File metadata
- Download URL: easydotdict-1.0.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
182d84cabfe245e4aafdbdbd4223a270b40dfef3af2634c5345406bc70e93009
|
|
| MD5 |
ecaa0a3355a3d935d31c7b19dd371963
|
|
| BLAKE2b-256 |
bb865ff58d17425c8c0baa8b484b148262c6e3a7ee94c498ba738836670eb8af
|
File details
Details for the file easydotdict-1.0.1-py3-none-any.whl.
File metadata
- Download URL: easydotdict-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78a0a7ffd135ab57cf588644a3eefaca1d788b81ee5bdce7da783c96cdf49008
|
|
| MD5 |
a1ef297e30c2ffe5aad2ef4284afbfa5
|
|
| BLAKE2b-256 |
b146d009d923084e865a94b82fb668b6acb055cf5cf482892205504dd6f65454
|