PySnooper: Effortless Python Debugging Without Print Statements

This repository profile is provided by osrepos.com, an open source repository discovery platform.

PySnooper: Effortless Python Debugging Without Print Statements

Summary

PySnooper is a powerful, yet simple, debugging tool for Python that eliminates the need for manual `print` statements. By adding a single decorator, developers can get a detailed, play-by-play log of function execution, including line-by-line tracing and variable value changes. It's designed for quick integration into any codebase without extensive setup.

Repository Information

Analyzed by OSRepos on April 20, 2026

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

PySnooper is an incredibly useful Python debugging tool that aims to completely replace the common practice of using print statements for debugging. Often described as "a poor man's debugger" or "like set -x for Python, but fancier," PySnooper provides a detailed, play-by-play log of your function's execution. It shows which lines ran, when they ran, and precisely when local variables changed their values.

The primary advantage of PySnooper is its simplicity. Instead of carefully crafting numerous print lines, you just add a single decorator, @pysnooper.snoop(), to the function you're interested in. This makes it exceptionally easy to integrate into any existing codebase, even large and complex ones, without requiring any setup or configuration.

Installation

Installing PySnooper is straightforward using pip:

$ pip install pysnooper

Other installation options include Conda, Arch Linux, and Fedora Linux, as detailed in the official repository.

Examples

Let's see PySnooper in action. Here's an example of a function that converts a number to binary, with the @pysnooper.snoop() decorator applied:

import pysnooper

@pysnooper.snoop()
def number_to_bits(number):
    if number:
        bits = []
        while number:
            number, remainder = divmod(number, 2)
            bits.insert(0, remainder)
        return bits
    else:
        return [0]

number_to_bits(6)

When number_to_bits(6) is called, PySnooper outputs a detailed log to stderr, showing each line executed, the values of variables at each step, and the elapsed time.

If you only need to trace a specific part of a function, you can use PySnooper within a with block:

import pysnooper
import random

def foo():
    lst = []
    for i in range(10):
        lst.append(random.randrange(1, 1000))

    with pysnooper.snoop():
        lower = min(lst)
        upper = max(lst)
        mid = (lower + upper) / 2
        print(lower, mid, upper)

foo()

This will generate a similar detailed log, but only for the code block wrapped by with pysnooper.snoop().

Why Use PySnooper

PySnooper stands out for its ease of use and powerful features:

  • Zero Setup: Simply add the decorator or use a with block. No complex configuration files or debugger interfaces are needed.
  • Detailed Tracing: Get a clear view of line execution order and variable changes.
  • Output Redirection: Redirect the snoop output to a file, stream, or callable instead of stderr, for example: @pysnooper.snoop('/my/log/file.log').
  • Watch Expressions: Monitor specific expressions that are not local variables, such as foo.bar or self.x["whatever"], using @pysnooper.snoop(watch=('foo.bar',)).
  • Call Depth: Trace into functions called by your snooped function using depth, for example: @pysnooper.snoop(depth=2).

For more advanced options and detailed usage, refer to the official documentation.

Links

Related repositories

Similar repositories that may be relevant next.

Google Skills: Agent Skills for Google Products and Technologies

Google Skills: Agent Skills for Google Products and Technologies

August 18, 2026

The `google/skills` repository offers a comprehensive collection of Agent Skills designed for Google products and technologies, including Google Cloud. It enables developers to easily integrate and leverage pre-built functionalities for various tasks, from infrastructure management to advanced AI/ML solutions. This resource streamlines the development of agentic applications within the Google ecosystem, providing a robust foundation for innovation.

googlegooglecloudskills
OpenSandbox: A Secure and Extensible Sandbox Runtime for AI Agents

OpenSandbox: A Secure and Extensible Sandbox Runtime for AI Agents

August 12, 2026

OpenSandbox is a powerful, general-purpose sandbox platform designed for AI applications. It provides secure, fast, and extensible runtime environments, supporting multi-language SDKs and Docker/Kubernetes deployments. This project is ideal for developing and evaluating AI agents in isolated, controlled settings.

aiai-agentai-infra
FastMCP: The Pythonic Framework for Model Context Protocol Applications

FastMCP: The Pythonic Framework for Model Context Protocol Applications

August 11, 2026

FastMCP is a robust, Pythonic framework developed by PrefectHQ, designed to simplify the creation of Model Context Protocol (MCP) servers and clients. It provides a comprehensive application framework for connecting Large Language Models (LLMs) to tools and data, handling complexities like schema generation, validation, and protocol lifecycle. As the standard framework for MCP, FastMCP empowers developers to build powerful LLM-integrated applications efficiently.

fastmcpmcpmodel-context-protocol
nanobot: An Ultra-Lightweight, Self-Hosted Personal AI Agent Framework

nanobot: An Ultra-Lightweight, Self-Hosted Personal AI Agent Framework

August 9, 2026

nanobot is an ultra-lightweight, open-source, self-hosted personal AI agent framework built in Python. It offers a WebUI, tools, memory, multi-agent workflows, and automation capabilities, making it a versatile solution for personal AI tasks. Users can deploy it across various platforms, including chat apps, for seamless integration.

ai-agentagent-frameworkpython

Source repository

Open the original repository on GitHub.

13 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️