back to home

cool-RR / PySnooper

Never use print for debugging again

16,606 stars
956 forks
31 issues
PythonShell

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing cool-RR/PySnooper in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/cool-RR/PySnooper)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

PySnooper - Never use print for debugging again **PySnooper** is a poor man's debugger. If you've used Bash, it's like for Python, except it's fancier. Your story: You're trying to figure out why your Python code isn't doing what you think it should be doing. You'd love to use a full-fledged debugger with breakpoints and watches, but you can't be bothered to set one up right now. You want to know which lines are running and which aren't, and what the values of the local variables are. Most people would use lines, in strategic locations, some of them showing the values of variables. **PySnooper** lets you do the same, except instead of carefully crafting the right lines, you just add one decorator line to the function you're interested in. You'll get a play-by-play log of your function, including which lines ran and when, and exactly when local variables were changed. What makes **PySnooper** stand out from all other code intelligence tools? You can use it in your shitty, sprawling enterprise codebase without having to do any setup. Just slap the decorator on, as shown below, and redirect the output to a dedicated log file by specifying its path as the first argument. Example We're writing a function that converts a number to binary, by returning a list of bits. Let's snoop on it by adding the decorator: The output to stderr is: Or if you don't want to trace an entire function, you can wrap the relevant part in a block: which outputs something like: Features If stderr is not easily accessible for you, you can redirect the output to a file: You can also pass a stream or a callable instead, and they'll be used. See values of some expressions that aren't local variables: Show snoop lines for functions that your function calls: **See Advanced Usage for more options.** <------ Installation with Pip The best way to install **PySnooper** is with Pip: Other installation options Conda with conda-forge channel: Arch Linux: Fedora Linux: Citing PySnooper If you use PySnooper in academic work, please use this citation format: License Copyright (c) 2019 Ram Rachum and collaborators, released under the MIT license. Media Coverage Hacker News thread and /r/Python Reddit thread (22 April 2019)