arbol | Arborescent Printouts in Python
Do you have a script, a command line tool, or some workflow in Python that has lots of print statements, and you can't make sense of it once it adds up to hundreds of lines on the console? Sounds familiar?
arbol organizes your stdout prints in a hierarchy that follows the structure of your code. Use a simple context manager to define the hierarchy and aprint instead of print, and voila. When the optional dependencies are installed, the output is colored with an exquisitely crafted combination of colors, making it even more visually appealing.
If you are wondering, arbol means tree in Spanish.
Why not use traditional Python logging? We made the choice of sticking to a plain and simple scheme that matches the usage of print statements.
Features
aprint: Drop-in replacement for the built-inprintfunctionasection: Context manager to create tree nodes with automatic timingsection: Decorator to wrap functions in a sectionacapture: Context manager to capture stdout/stderr from third-party code- Configuration: Control depth, colors, timing display via
Arbolclass
Installation
Install with pip:
pip install arbol
Or with optional color support:
pip install arbol[colors]
Optional Dependencies
For colors, install the ansicolors package:
pip install ansicolors
For color support on all operating systems (particularly Windows), install colorama:
pip install colorama
Note: both are optional — arbol works fine without them.
Example
from arbol import Arbol, aprint, section, asection, acapture
# Limit the tree depth:
Arbol.max_depth = 4
# Use aprint instead of print
aprint('Test')
# Decorate functions to wrap them in a section:
@section('function')
def fun(x):
if x >= 0:
with asection('recursive call'):
aprint(f"f(x)+1={fun(x - 1)}")
# Context manager lets you go down one level in the tree:
with asection('a section'):
aprint('a line')
aprint('another line')
aprint('we are done \n or are we? \n someone gotta check!')
with asection('a subsection'):
aprint('another line')
aprint('we are done')
# Works through function calls:
fun(2)
# Capture stdout from third-party code (experimental):
with acapture():
print("This gets captured")
# Disable elapsed time display:
Arbol.elapsed_time = False
fun(100)
aprint('demo is finished...')
# Turn off all output:
Arbol.enable_output = False
aprint('you will not see this')
Output:
Configuration
All settings are class attributes on Arbol:
| Attribute | Default | Description |
|---|---|---|
enable_output |
True |
Set to False to suppress all output |
elapsed_time |
True |
Set to False to hide timing information |
max_depth |
math.inf |
Maximum tree depth (deeper sections show truncation) |
colorful |
True |
Set to False to disable colors |
passthrough |
False |
Set to True to bypass tree formatting entirely |
Color attributes (c_text, c_scaffold, c_timing, c_section, c_truncation) can also be customized with hex color codes.
Roadmap
Ideas we might consider, from serious to speculative:
- More color styles to choose from
- Intercept stdout from C code so that printouts from native libraries are formatted too (unclear if possible)
- Generate tree automatically by inspecting stack
- Interoperability with the logging package
- Better multi-thread/process support — currently printouts get interleaved. One idea: capture outputs per-thread and display them in order when done.
Development
make install # Install hatch and set up environment
make test # Run tests
make demo # Run the demo
make lint # Run linter (ruff)
make format # Format code (ruff)
make check # Run all checks (lint + format)
make publish # Bump version and release
Contributions
Pull requests welcome!
Authors
- Loic A. Royer (@loicaroyer)
- Ahmet Can Solak (@_ahmetcansolak)
Metadata
Release files for arbol 2026.2.22
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| arbol-2026.2.22.tar.gz | 8.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| arbol-2026.2.22-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.1 kB
Release files / arbol-2026.2.22.tar.gz
| Download URL | arbol-2026.2.22.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ec531f8f3b06283da0471d4e351ff195f79709d5ab2d71a59c4275b29219d43
|
|
BLAKE2b-256 checksum How to use checksums |
364ff4a19090168b83c67423129d034f4d0075affc193e93fed8fb2a282cc959
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 22, 2026.
Transparency logRelease files / arbol-2026.2.22-py3-none-any.whl
| Download URL | arbol-2026.2.22-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3f8f7b226b4ff8fcc7484011dbbcd096f416be7a0f00be3828893e49beb35b8
|
|
BLAKE2b-256 checksum How to use checksums |
8ce0162aed5d9e990c0d49286def7d9e5163536667ddb881292efe9ee3237f2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 22, 2026.
Transparency log