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"
}
}
]
}
Metadata
Release files for easytree 1.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 | |
|---|---|---|---|
| easytree-1.0.1.tar.gz | 14.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| easytree-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.6 kB
Release files / easytree-1.0.1.tar.gz
| Download URL | easytree-1.0.1.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6dcd87e7a4d54a0ade60037679ae1cd02539962b1b6346affb74394b10c24d7a
|
|
BLAKE2b-256 checksum How to use checksums |
cffe88cfcd39a785e5d22a456aea65cf48e8e8dc17d0e6acdcf3b12f56d7fe3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / easytree-1.0.1-py3-none-any.whl
| Download URL | easytree-1.0.1-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17df62a04bd6d26c46f6a95248ab01f176096523bb3dbcbf334102694392b428
|
|
BLAKE2b-256 checksum How to use checksums |
d69fcc7da6ed5eaa8ae02fafeb90c85812311502567077b185e437d10565f3c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|