easytree
A recursive dot-styled defaultdict to read and write deeply-nested trees
Documentation
Documentation is hosted on read the docs
Installation
pip install easytree
Quickstart
>>> import easytree
>>> tree = easytree.dict()
>>> tree.foo.bar.baz = "Hello world!"
>>> tree
{
"foo": {
"bar": {
"baz": "Hello world!"
}
}
}
Creating trees that combine both list and dict nodes is easy
>>> friends = easytree.list()
>>> friends.append({"firstname":"Alice"})
>>> friends[0].address.country = "Netherlands"
>>> friends[0]["interests"].append("science")
>>> friends
[
{
"firstname": "Alice",
"address": {
"country": "Netherlands"
},
"interests": [
"science"
]
}
]
Writing deeply-nested trees with list nodes is easy with a context-manager:
>>> profile = easytree.dict()
>>> with profile.friends.append({"firstname":"Flora"}) as friend:
... friend.birthday = "25/02"
... friend.address.country = "France"
>>> profile
{
"friends": [
{
"firstname": "Flora",
"birthday": "25/02",
"address": {
"country": "France"
}
}
]
}
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
easytree-1.0.1.tar.gz
(14.8 kB
view details)
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
easytree-1.0.1-py3-none-any.whl
(14.8 kB
view details)
File details
Details for the file easytree-1.0.1.tar.gz.
File metadata
- Download URL: easytree-1.0.1.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dcd87e7a4d54a0ade60037679ae1cd02539962b1b6346affb74394b10c24d7a
|
|
| MD5 |
4034f74598f0b6db7823b11aeea4edb1
|
|
| BLAKE2b-256 |
cffe88cfcd39a785e5d22a456aea65cf48e8e8dc17d0e6acdcf3b12f56d7fe3d
|
File details
Details for the file easytree-1.0.1-py3-none-any.whl.
File metadata
- Download URL: easytree-1.0.1-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17df62a04bd6d26c46f6a95248ab01f176096523bb3dbcbf334102694392b428
|
|
| MD5 |
213feab7b34cc29b0159e2879e589745
|
|
| BLAKE2b-256 |
d69fcc7da6ed5eaa8ae02fafeb90c85812311502567077b185e437d10565f3c0
|