Python's Missing Debug Print Command

0.12.2 · active · verified Sat Apr 11

devtools provides an enhanced debug print command for Python, offering formatted output with file, line number, function information, and variable names. It's designed to be more readable than the standard `print()` function, especially for complex data structures. The library is actively maintained, with its current version being 0.12.2, and has a consistent release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the core `debug()` function to print variables, expressions, and complex data structures with enhanced formatting, including file, line number, and function context. It shows usage with simple variables, lists, function arguments, and class attributes.

from devtools import debug

def example_function(a, b):
    result = a * b
    debug(a, b, result)
    return result

my_list = [1, 2, {'key': 'value', 'nested': [3, 4]}]
debug(my_list)

example_function(10, 5)

class MyClass:
    def __init__(self, name):
        self.name = name
        self.data = {'id': 123, 'status': 'active'}

obj = MyClass('TestObject')
debug(obj.name, obj.data)

view raw JSON →