HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
cool-RR
PySnooper
Python2019–2023
cool-RR / PySnooper

PySnooper

Never use print for debugging again

6Distinct people
10Mentions
0Explicit recommenders
16.6KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Never use print for debugging again

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year10 dated mentions

Observed mentions: 2019-04-22 10:29:38 UTC to 2023-01-15 21:49:15 UTC.

012342019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 4 mentions; 2 submissions, 2 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments20212022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC422
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC101
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC303
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC101

What Hacker News says

10 sources
I use PySnooper[1] when code behavior deviates inscrutably from my mental model. Like Icecream, PySnooper exhorts, "Never use print for debugging again." A simple example: import pysnooper @pysnooper.snoop() def add_up(numbers): total = 0 for number in numbers: total += number return total add_up([123, 456]) When run, PySnooper prints the activity of the decorated function or method: $ python example.py Source path:... /home/joel/example.py Starting var:.. numbers = [123, 456] 08:46:58.742543 call 4 def add_up(numbers): 08:46:58.742692 line 5 total = 0 New var:....... total = 0 08:46:58.742722 line 6 for number in numbers: New var:....... number = 123 08:46:58.742755 line 7
Read the rest
total += number Modified var:.. total = 123 08:46:58.742787 line 6 for number in numbers: Modified var:.. number = 456 08:46:58.742818 line 7 total += number Modified var:.. total = 579 08:46:58.742847 line 6 for number in numbers: 08:46:58.742876 line 8 return total 08:46:58.742898 return 8 return total Return value:.. 579 Elapsed time: 00:00:00.000405 [1] https://github.com/cool-RR/PySnooper
In Icecream: Never use print() to debug again in Python
Nice article. In particular the -i flag seems really useful. I'd like to add two packages I learned about recently that I like A LOT: pyrasite and PySnooper. Use pyrasite to "attach" to an existing running Python process (i.e. you forgot to instrument the app, but it has a bug in it, how can you debug?) (1) Install pyrasite (2) Get the PID of the running process (3) Run `pyrasite <pid> dumpstackz0.py` where dumpstackz0.pycontains `import traceback; traceback.print_stack()` (4) The stacktrace will be printed in the stdout/stderr of the running application Use PySnooper instead of print-debugging—just add a decorator to any python function to get detailed debug info like you normally would get from a full debugger: (A) code: https://github.com/cool-RR/PySnooper (B) pypi: https://pypi.org/project/PySnooper/ (C) talk: https://www.youtube.com/
Read the rest
In Guide to Python Debugging
>I don't understand why you think print or log debugging is inherently bad. I use it myself all the time, but it just shows the weakness of the tooling that people have to resort to such measures. Fortunately, some people are working on it [1]. >Also, it's part of the format string and not a special print function so that it can be used for logs and other output as well, not just the console. Since print (and hypothetical debug_print) are no longer statements like in 2.x, there's nothing preventing them from returning the string that's supposed to be printed. For example print's keyword file is sys.stdout by default. Why not borrow from Common Lisp's format and make it return the string if file=None is passed? Then you could do logging.warning(debug_print('Unusual situation', foo, bar, file=None)) and it would print "WARNING: Unusual situ
Read the rest
ation: foo=foo_value, bar=bar_value" to the logs. It's so much clearer. [1] https://github.com/cool-RR/pysnooper
In What's Coming in Python 3.8

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.