nestify
nestify is a tiny utility that transforms flat dictionaries with path-like keys into proper nested structures.
Think of it as the inverse of flatten:
from nestify import nestify
data = {
"a.b.c": 1,
"a.d": 2,
"x": 3
}
print(nestify(data))
# => {"a": {"b": {"c": 1}, "d": 2}, "x": 3}
✨ Features
-
Custom separators
Not limited to dots (.) — use/,:,::, or any string as a separator. -
Conflict resolution policies
Choose how to handle conflicts:forbid_mixed: strict mode, disallow mixing dict/non-dict (default).merge_dicts: merge dictionaries recursively, warn on key overlaps.overwrite: always overwrite existing values, with a warning.
-
Recursive processing
Values that are dictionaries themselves are also expanded. -
Safe & predictable
Warnings and errors make conflicts explicit, avoiding silent data corruption.
🔧 Usage Examples
Basic Expansion
from nestify import nestify
nestify({"a.b": 1, "a.c": 2})
# => {"a": {"b": 1, "c": 2}}
Custom Separator
from nestify import nestify
nestify({"root/child": 42}, separator="/")
# => {"root": {"child": 42}}
Conflict Resolution
from nestify import nestify
# Overwrite mode
nestify({"a.b": 1, "a.b": 2}, conflict_policy="overwrite")
# => {"a": {"b": 2}}
💡 Why nestify?
When working with configs, JSON/YAML, or flattened exports (from APIs, databases, etc.), you often get keys like "user.profile.name". nestify makes it effortless to convert them into proper nested dicts.
📦 Installation
pip install nestify
🧾 License
MIT License. See LICENSE for details.
Metadata
Release files for nestify 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nestify-0.0.1.tar.gz | 5.7 kB | Details |
Release files / nestify-0.0.1.tar.gz
| Download URL | nestify-0.0.1.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34374fdfac0f170a2ee4a8332e09eb263441e3a9ae6e8e2ef0b176b8ce819afd
|
|
BLAKE2b-256 checksum How to use checksums |
77deb45ecb01caf306ef26cffcf56bdc5e7a7e450b881c918c6ace53284926b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|