easydotdict
Navigate nested dictionaries with the simplicity of attribute access.
Zero dependencies. Python 3.8+.
from easydotdict import dotdict
d = dotdict({"user": {"profile": {"name": "Alice"}}})
# Read deeply with dot notation
print(d.user.profile.name) # Alice
print(d["user"].profile.name) # same, dual access
# Safe missing-key access — no exceptions
print(d.user.email) # None
# Auto-create nested paths on assignment
d.config.database.host = "localhost"
# Scalar auto-conversion — string becomes a key
d.name = "Alice"
d.name.character = 5 # {"name": {"Alice": {"character": 5}}}
# Deep path string methods
d.put("server.port", 8080)
print(d.dig("user.name")) # Alice
# Compare, diff, and migrate
v1 = dotdict({"app": {"debug": True}})
v2 = dotdict({"app": {"debug": False, "version": "2.0"}})
changes = v1.diff(v2)
v1.patch(changes) # v1 now matches v2
# Recursive flatten and restore
flat = d.flatten()
restored = dotdict.unflatten(flat)
# Deep merge with key preservation
d.merge({"settings": {"theme": "dark"}})
# Pretty-printed JSON output
print(d)
Features
| Category | Capabilities |
|---|---|
| Access | Dot notation (d.user.name), bracket notation (d["user"]), dual interchangeability |
| Safety | Missing keys return None — no KeyError or AttributeError |
| Auto-vivification | d.a.b.c = value creates intermediate structures automatically |
| Scalar conversion | d.name = "Alice"; d.name.x = 1 promotes scalars to nested dicts |
| Deep paths | dig(), get(), put(), has() with dot-separated strings; handles list indices (users.0.name) |
| Flatten / Unflatten | Recursive flatten to dot-keys and restoration via unflatten() |
| Deep merge | update() and merge() merge recursively, preserving existing keys |
| Diff & Patch | diff(other) produces {path: {"from": ..., "to": ...}}; patch() applies changes |
| Batch operations | set_many({path: value}) and delete(*paths) for bulk mutations |
| Search | find(name) locates all dot-paths matching a key name anywhere in the tree |
| Cursor | Lightweight views into nested paths — mutations affect the original |
| Type validation | expect(schema) validates types at runtime; @expect_schema for functions |
| Change tracking | on_change(path, cb) fires callbacks on mutation |
| Freeze | freeze() / unfreeze() enforces immutability; @freeze for return values |
| Decorators | @dotdictify converts arguments, @defaults supplies fallbacks |
| Comparisons | Scalars support <, >, <=, >= and f-string formatting |
| Serialisation | to_dict() unwraps to plain dict / list; pretty-printed JSON via print() |
| Compatibility | Full dict subclass — keys(), items(), pop(), len(), in, etc. all work |
Install
pip install easydotdict
Documentation
Full API reference, edge case table, and decorator guide: docs.md
Real-world examples:
api_response.py— consume a JSON API endpointapp_config.py— load, edit, and persist application configurationproduct_catalog.py— enrich GitHub repository dataconfig_manager.py— validate, watch, freeze, and bulk-override settingsdata_migration.py— diff, patch, find, and validate between data versionsgithub_stars.py— analyse repository metadata with find, diff, cursor, and expect
License
MIT
Metadata
Release files for easydotdict 1.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| easydotdict-1.1.3.tar.gz | 10.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| easydotdict-1.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.5 kB
Release files / easydotdict-1.1.3.tar.gz
| Download URL | easydotdict-1.1.3.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7160ed4ac6781a453aa400101835ee6b8305b0316a751e98b6f5e82b87c34260
|
|
BLAKE2b-256 checksum How to use checksums |
78683a334799dbac213eb6287792bc82bf955e74a26332647e3196ad10178576
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / easydotdict-1.1.3-py3-none-any.whl
| Download URL | easydotdict-1.1.3-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca7e663d63562fff6493c8039e4afddefdcc45929934bce27616c7150fb67632
|
|
BLAKE2b-256 checksum How to use checksums |
c9c843ce5610ca7f3d480d39cdd1816454fca99a7b73ccfe826a8e04c4a118cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|