A powerful, modern tree manipulation library for Python with an immutable-by-default API.
>>, |, & operatorsfrom AlgoTree import Node, parse_tree, pretty_tree
# Create trees with constructor
tree = Node("root",
Node("src", Node("main.py"), Node("utils.py")),
Node("docs", Node("README.md"))
)
# Or parse from text
tree = parse_tree("""
root
├── src
│ ├── main.py
│ └── utils.py
└── docs
└── README.md
""")
# Visualize
print(pretty_tree(tree))
# Transform (immutably)
filtered = tree.filter(lambda n: not n.name.startswith("."))
with_attrs = tree.map(lambda n: n.with_attrs(visited=True))
pip install AlgoTree
&, |, ~ operators>> or |MIT License - see LICENSE for details.