Immediately see which variable held the bad value that caused a crash, without adding print statements.
Enable better error output globally for a Django web app via a middleware component.
Use colored, readable tracebacks in your test suite to make failing tests easier to diagnose.
Disable before production deployment to avoid leaking sensitive variable values in logs or error pages.
Better-exceptions is a Python package that makes error messages easier to read when something goes wrong in your code. By default, Python prints a stack trace when a crash happens, which shows you the sequence of function calls that led to the error, but it can be hard to parse. Better-exceptions reformats that output with colors and adds the actual values of variables at the moment the crash occurred, so you can see what data caused the problem without adding extra print statements. Setting it up is minimal. You install it through pip, Python's standard package manager, and then set a single environment variable to turn it on. After that, it activates automatically for any Python script you run, with no code changes needed. A security note in the README advises turning it off in production environments because printing variable values in logs can expose sensitive information like passwords or user data. The package works in several contexts beyond basic script execution. It can be used in the interactive Python shell, in Django web applications through a middleware component, and in Python's built-in testing framework. Each integration has slightly different setup instructions described in the README. If the improved output does not appear after setup, the README walks through common causes: the environment variable not being set permanently, another package overriding Python's error handler, or a supporting file getting accidentally deleted during updates.
← qix- on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.