nutree
Nutree lets you organize and query arbitrary Python objects as a tree — with clones, diffing, and graph export built in.
Trees and nodes behave like familiar Python containers wherever that makes sense — len(tree) counts nodes,
for node in tree: ... walks the tree depth-first, and value in tree tests membership.
Lookup (tree[value]) matches by id or by the wrapped data (not by position, since a tree has no natural order).
[!TIP] Take the Tour and Read the Docs for more.
Nutree Facts
Handle multiple references of single objects ('clones')
Search by name pattern, id, or object reference
Compare two trees and calculate patches
Unobtrusive handling of arbitrary objects
Save as DOT file and graphwiz diagram
Nodes can be plain strings or objects
(De)Serialize to (compressed) JSON
Save as Mermaid flow diagram
Multiple traversal methods
Generate random trees
Convert to RDF graph
Fully type annotated
Typed child nodes
Memory efficient
Pretty print
Navigation
Filtering
Fast
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")
tree.print()
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>
Nodes can holdarbitrary objects (not just strings):
alice = Person("Alice", age=23, guid="{123-456}")
tree.add(alice)
# Lookup nodes by object, data_id, name pattern, ...
alice_node = tree[alice]
assert isinstance(alice_node.data, Person)
del tree[alice]
Take the Tour and Read the Docs for more.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file nutree-1.2.0.tar.gz.
File metadata
- Download URL: nutree-1.2.0.tar.gz
- Upload date:
- Size: 78.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2e505e002df01eeb6a06aca483a70aaa341adc62ab3ebddfabd50a15421edeb
|
|
| MD5 |
ca15233dca463e972655bf9c23f21459
|
|
| BLAKE2b-256 |
21ff019829f01b17f4c39ebc53f069890aeb8145fd86b08e09ab89110b05465d
|
Provenance
The following attestation bundles were made for nutree-1.2.0.tar.gz:
Publisher:
release.yml on mar10/nutree
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nutree-1.2.0.tar.gz -
Subject digest:
f2e505e002df01eeb6a06aca483a70aaa341adc62ab3ebddfabd50a15421edeb - Sigstore transparency entry: 2479180810
- Sigstore integration time:
-
Permalink:
mar10/nutree@69ed6cf5dd7128971e64dd1699c7ced6f934453d -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/mar10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@69ed6cf5dd7128971e64dd1699c7ced6f934453d -
Trigger Event:
push
-
Statement type:
File details
Details for the file nutree-1.2.0-py3-none-any.whl.
File metadata
- Download URL: nutree-1.2.0-py3-none-any.whl
- Upload date:
- Size: 57.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e44f932b657a213844df3b47f091c67dee92db70845c01e503a387a5b01aad1
|
|
| MD5 |
3bd5bb46120c54b5e5d5ff3fb354d719
|
|
| BLAKE2b-256 |
dce422ef7b69b9849e9b2b6d36a830cfcedefa7670129de0b01db38be32bcca4
|
Provenance
The following attestation bundles were made for nutree-1.2.0-py3-none-any.whl:
Publisher:
release.yml on mar10/nutree
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nutree-1.2.0-py3-none-any.whl -
Subject digest:
9e44f932b657a213844df3b47f091c67dee92db70845c01e503a387a5b01aad1 - Sigstore transparency entry: 2479180878
- Sigstore integration time:
-
Permalink:
mar10/nutree@69ed6cf5dd7128971e64dd1699c7ced6f934453d -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/mar10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@69ed6cf5dd7128971e64dd1699c7ced6f934453d -
Trigger Event:
push
-
Statement type: