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"
            }
        }
    ]
}

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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easytree-1.0.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

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

Hashes for easytree-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6dcd87e7a4d54a0ade60037679ae1cd02539962b1b6346affb74394b10c24d7a
MD5 4034f74598f0b6db7823b11aeea4edb1
BLAKE2b-256 cffe88cfcd39a785e5d22a456aea65cf48e8e8dc17d0e6acdcf3b12f56d7fe3d

See more details on using hashes here.

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

Hashes for easytree-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 17df62a04bd6d26c46f6a95248ab01f176096523bb3dbcbf334102694392b428
MD5 213feab7b34cc29b0159e2879e589745
BLAKE2b-256 d69fcc7da6ed5eaa8ae02fafeb90c85812311502567077b185e437d10565f3c0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page