Skip to main content

easytree

pythons tests and coverage PyPI version Documentation Status Code style: black Coverage

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)

Source distribution for easytree 1.0.1
File Size Uploaded
easytree-1.0.1.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easytree 1.0.1
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page