explaingit

cool-rr/pysnooper

Analysis updated 2026-06-24

16,586PythonAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

PySnooper is a Python debugging tool you add as a decorator to any function to log every line that runs and every variable that changes, with timestamps.

Mindmap

mindmap
  root((PySnooper))
    Inputs
      Decorated function
      Optional log path
      Watched expressions
    Outputs
      Line by line trace
      Variable change log
      Timestamps
    Use Cases
      Debug without print statements
      Trace a tricky function
      Capture a bug repro to a file
    Tech Stack
      Python
      pip
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Debug a Python function by adding one decorator instead of scattering print calls

USE CASE 2

Capture a line by line trace of a tricky bug to a log file for later review

USE CASE 3

Trace not only one function but the inner functions it calls by setting a depth value

USE CASE 4

Watch a non local expression like an attribute path during a run

What is it built with?

Pythonpip

How does it compare?

cool-rr/pysnooperanthropics/claude-quickstartsrendercv/rendercv
Stars16,58616,58716,590
LanguagePythonPythonPython
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdevelopergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
MIT lets you use, modify, and ship PySnooper in commercial projects as long as you keep the copyright notice.

In plain English

PySnooper is a lightweight debugging tool for Python that eliminates the need to scatter print statements throughout your code. The idea is simple: instead of manually writing print lines to track what your code is doing, you add a single decorator line above any function and PySnooper automatically logs every line that runs, every variable that changes, and the exact moment each change happens. It is described as a poor man's debugger, you do not need to set up a full debugging environment, configure breakpoints, or do any special preparation. You just add the decorator and run your code as normal. The output shows a timestamped, line-by-line trace of what happened inside the function, including new variables being created and their values changing over time. If you do not want to trace an entire function, you can wrap just a specific block of code inside a with statement instead. By default the trace output goes to stderr, but you can redirect it to a log file by passing a file path to the decorator. You can also tell it to watch specific expressions that are not local variables, and you can ask it to trace not just your function but also the functions your function calls, by setting a depth option. PySnooper is installed via pip and is also available through conda and in package managers for Arch Linux and Fedora. It is open source under the MIT license and has been cited in academic work.

Copy-paste prompts

Prompt 1
Show me how to install pysnooper with pip and decorate a function to trace its execution
Prompt 2
Use pysnooper to trace only a specific with block inside a larger function
Prompt 3
Redirect pysnooper output to a rotating log file in a long running script
Prompt 4
Compare pysnooper to using pdb and the standard logging module for everyday debugging
Prompt 5
Set depth so pysnooper also traces the helper functions called from my decorated function

Frequently asked questions

What is pysnooper?

PySnooper is a Python debugging tool you add as a decorator to any function to log every line that runs and every variable that changes, with timestamps.

What language is pysnooper written in?

Mainly Python. The stack also includes Python, pip.

What license does pysnooper use?

MIT lets you use, modify, and ship PySnooper in commercial projects as long as you keep the copyright notice.

How hard is pysnooper to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is pysnooper for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub cool-rr on gitmyhub

Verify against the repo before relying on details.