Skip to main content

Tree data structures for primates

Project description

logo nutree

Build Status Latest Version License Documentation Status Coverage Status Code style: black Released with: Yabs StackOverflow: nutree

Elegant trees for primates™

Nutree is a Python library for tree data structures with an intuitive, yet powerful, API.

Nutree Facts

Search by name pattern, id, or object reference
Handle multiple references of single objects
Store plain strings or arbitrary objects
Different traversal methods
(De)Serialize to JSON
Pretty print
Navigation
Filtering

Example

A simple tree, with text nodes

from nutree import Tree, Node

tree = Tree("Store")

n = tree.add("Records")

n.add("Let It Be")
n.add("Get Yer Ya-Ya's Out!")

n = tree.add("Books")
n.add("The Little Prince")

print(tree.format())
Tree<'Store'>
├── 'Records'
│   ├── 'Let It Be'
│   ╰── "Get Yer Ya-Ya's Out!"
╰── 'Books'
    ╰── 'The Little Prince'

Tree nodes wrap the data and also expose methods for navigation, searching, iteration, ...

records_node = tree["Records"]
assert isinstance(records_node, Node)
assert records_node.name == "Records"

print(records_node.first_child)
Node<'Let It Be', data_id=510268653885439170>

Read the Docs for more.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nutree-0.0.1a4.tar.gz (14.9 kB view hashes)

Uploaded Source

Built Distribution

nutree-0.0.1a4-py3-none-any.whl (14.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page