[FYI][all] PySnooper, a poor man's debugger

Ben Nemec openstack at nemebean.com
Mon Apr 22 16:51:49 UTC 2019



On 4/22/19 8:32 AM, Artom Lifshitz wrote:
> tl;dr Instead of debugging with LOG.debug and/or print() statements
> all over the place, use the pysnooper decorator [1].
> 
> I came across this on Hacker News this morning - if you're like me and
> are too lazy to invest in learning a real debugger, and instead do it
> with LOG.debug/print()s all over the place, pysnooper might be useful
> to you. This line from the README feels particularly relevant to me ;)

I'm going to mildly object to the characterization of print and log 
debugging as "lazy". I've spent plenty of time in debuggers over the 
years and in many cases I just prefer a simple print over stepping 
through a huge number of lines of code. Both debugging techniques have 
their place and nobody should feel bad because they chose one over the 
other.

> 
>> What makes PySnooper stand out from all other code intelligence tools?
>> You can use it in your sh***y, sprawling enterprise codebase without having
>> to do any setup.
> 
> I tried it out with a random Nova unit test by decorating the function
> being tested, and it gave me the expected analysis of how the function
> executed.
> 
> Just sharing this, I hope it might be useful to someone :)

I've starred it. It looks a bit like bash's xtrace on steroids, which is 
something I use quite a lot when debugging bash scripts.

> 
> [1] https://github.com/cool-RR/pysnooper
> 



More information about the openstack-discuss mailing list