traceback_with_variables
traceback_with_variables is a Python debugging library that automatically captures and displays local variable values when exceptions occur. It eliminates manual logging of exception context by hooking into Python's traceback system to show every variable at each stack frame.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | andy-landy/traceback_with_variables |
| Owner | andy-landy |
| Primary language | Python |
| License | MIT — OSI-approved |
| Stars | 704 |
| Forks | 31 |
| Open issues | 9 |
| Latest release | v2.2.0 (2025-02-21) |
| Last updated | 2025-10-24 |
| Source | https://github.com/andy-landy/traceback_with_variables |
What traceback_with_variables is
The library intercepts Python's exception handling via traceback hooks or decorators/context managers to iterate through stack frames and extract local variables. It provides customizable formatting, color output, and works across Jupyter, standard scripts, and CLI invocation without code modification.
Get the traceback_with_variables source
Clone the repository and explore it locally.
git clone https://github.com/andy-landy/traceback_with_variables.gitcd traceback_with_variables# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Import `activate_by_import` early in entry point for global activation, or use `@prints_exc` decorator or `with printing_exc()` context for granular scope control.
- Customize `fmt` object (max_value_str_len, skip_files_except, custom_var_printers) to avoid dumping excessive data or sensitive variables in your environment.
- For logger integration, wrap logger with `LoggerAsFile()` adapter; ensure log rotation and size limits are configured, as large tracebacks can bloat log volume.
- Test color output on target platforms (Windows Console ANSI support has quirks); library reports cross-platform support but validate in your deployment environment.
- Consider exception filtering strategy early: decide whether to apply library globally or only to specific functions/modules to manage output verbosity and overhead.
When to avoid it — and what to weigh
- Production systems with strict performance requirements — Capturing full local scope for every frame in large/nested stacks incurs overhead. README explicitly suggests 'small-scale production' only; not recommended for high-throughput services.
- Large or sensitive object serialization concerns — The library dumps all local variables to output/logs including potentially large data structures or secrets. Requires careful configuration of filters and max string lengths to avoid exposing sensitive data.
- Strict, pre-existing exception-handling architecture — If your codebase has a custom exception context system or proprietary traceback processing, integrating this library may conflict or duplicate effort. Legacy systems with custom metaclass hooks warrant review.
- Real-time systems with strict latency SLAs — Frame introspection and string formatting can introduce unpredictable latency spikes. Not suitable for hard real-time or ultra-low-latency constraints.
License & commercial use
Licensed under MIT (MIT License), a permissive OSI-approved license. Grants rights to use, modify, distribute, and sublicense, subject only to preservation of copyright and license notices.
MIT is a permissive open-source license; commercial use is explicitly permitted. However, this is a debugging tool; ensure your commercial product's exception handling and variable logging comply with your data protection and privacy policies, especially regarding customer data exposure in logs.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
Library dumps all local variables to output/logs by default. In production, this can leak secrets (passwords, tokens, API keys) if present in scope. Mitigation: use `custom_var_printers` or `skip_files_except` to filter sensitive values, enforce max string length, and audit what reaches logs. No security audit or CVE history evident in provided data.
Alternatives to consider
ipdb / pdb (Python built-in debugger)
Interactive debugging with full REPL access; better for development but requires manual breakpoints and human presence. Not suitable for unattended/production scenarios.
Better Exceptions (better_exceptions / rich.traceback)
Provide enhanced traceback formatting and syntax highlighting but do not capture live variable state. Lighter-weight than traceback_with_variables but less diagnostic power.
Custom exception context logging (manual try-except + logging)
Full control and minimal overhead; widely used in production systems. Requires more boilerplate and discipline to maintain comprehensive logging across all error paths.
Build on traceback_with_variables with DEV.co software developers
Reduce exception-hunting time by automatically capturing variable state at each stack frame. Install traceback_with_variables and integrate it into your development and staging workflows.
Talk to DEV.coRelated on DEV.co
Explore the category and the services that help you build with it.
traceback_with_variables FAQ
Does it work in production?
Will it expose secrets or sensitive data?
Can I use it with async or threaded code?
How does it compare to full debuggers like PyCharm's debugger?
Software developers & web developers for hire
From first prototype to production, DEV.co delivers software development services around tools like traceback_with_variables. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across open-source observability and beyond.
Streamline Python Debugging
Reduce exception-hunting time by automatically capturing variable state at each stack frame. Install traceback_with_variables and integrate it into your development and staging workflows.