Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the features of the Python debugging tool PySnooper

Shulou Source: shulou.com Published: 2022-06-02 09:46:43 10月04日 Update

This article mainly explains "Python debugging tool PySnooper has what features", the explanation content in the article is simple and clear, easy to learn and understand, please follow the idea of Xiaobian slowly in-depth, together to study and learn "Python debugging tool PySnooper has what features"!

PySnooper is so simple to use that developers can use it in any large code base without any setup. You simply add decorators and specify the path to the log output address by specifying its path as the first argument.

PySnooper has 7047 Stars and 371 Forks on GitHub (https://github.com/cool-RR/PySnooper)

example

Here is a function that returns a binary list. We just need to add the @ pisnooper.snoop() decorator:

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)

characteristics

stderr, you can output the selection to the specified file:

@pysnooper.snoop( /my/log/file.log )

View the variable values of some non-local variables:

@pysnooper.snoop(variables=( foo.bar , self.whatever ))

Snoop lines showing functions called by functions:

@pysnooper.snoop(depth=2)

Thank you for reading, the above is "Python debugging tool PySnooper what features" content, after the study of this article, I believe that we have a deeper understanding of Python debugging tool PySnooper what features this problem, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Tags: Features tools functions learning content address path output binary code parameters variables just that is local huge developers ideas situations files Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Redmi MySQL Shulou Tech Info Xiaomi