debug dojo¶
🏣 debug dojo, a place for zen debugging
debug-dojo is a Python package providing utilities for enhanced
debugging and inspection in the terminal. It leverages
rich
for beautiful output and
offers helpers for side-by-side object comparison, improved tracebacks
from rich
, and easy integration with different debuggers – debugpy
,
pudb
, pdb
, and ipdb
.
Features¶
- Convenient CLI Quickly run your code with debugging tools enabled.
- Simple API: Install all tools or only what you need.
- Debugger integration: Quickly enable Debugpy, PuDB, PDB, or IPDB as your default pre-configured debugger.
- Rich tracebacks: Get readable, colorized tracebacks for easier debugging.
- Side-by-side object inspection: Visually compare Python objects, their attributes, and methods in the terminal.
- Configuration: Easily configure the debugging tools using
dojo.toml
orpyproject.toml
.
Usage¶
CLI¶
Run your Python script with debugging tools enabled using the
debug-dojo
command:
You can optionally set configuration, verbose mode, and specify the debugger type. Both script files and modules are supported:
dojo can let you debug into:
- any Python script –
dojo my_script.py
- any runnable module –
dojo -m my_module
- or even an executable,
dojo -e my_executable
(likepytest
)
From the code¶
In the PuDB
style, you can install all debugging tools and enter the
debugging mode with a single command:
Features in debugging mode (when debug_dojo.install
is used)¶
When you use import debug_dojo.install; b()
, the following convenience functions are injected into Python’s builtins, making them globally available within your debugging session:
b()
: Sets a breakpoint using the debugger configured indebug-dojo
. This is equivalent to callingbreakpoint()
but respects yourdebug-dojo
debugger settings.p(obj)
: Pretty prints an object usingrich.print
, providing enhanced readability for complex data structures.i(obj)
: Inspects an object usingrich.inspect
, offering a detailed, colorized view of its attributes and methods.c(obj1, obj2)
: Compares two Python objects side-by-side usingdebug-dojo
’s comparison utility, highlighting differences for easier debugging.
Installation¶
The package is available on PyPI and can be installed using standard Python package management tools.
You can also use poetry
or uv
to add it to your project:
Note that dojo most likely will not work when installed via pipx
or
uvx
, as it relies on the current Python environment dependencies.