[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-2717":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":17,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":29,"readmeContent":30,"aiSummary":31,"trendingCount":16,"starSnapshotCount":16,"syncStatus":32,"lastSyncTime":33,"discoverSource":34},2717,"PySnooper","cool-RR\u002FPySnooper","cool-RR","Never use print for debugging again","",null,"Python",16589,959,228,28,0,1,4,69.85,"MIT License",false,"master",[24,25,26,27,28],"debug","debugger","introspection","logging","python","2026-06-12 04:00:15","# PySnooper - Never use print for debugging again\n\n**PySnooper** is a poor man's debugger. If you've used Bash, it's like `set -x` for Python, except it's fancier.\n\nYour 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.\n\nYou want to know which lines are running and which aren't, and what the values of the local variables are.\n\nMost people would use `print` lines, in strategic locations, some of them showing the values of variables.\n\n**PySnooper** lets you do the same, except instead of carefully crafting the right `print` 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.\n\nWhat 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.\n\n## Example\n\nWe're writing a function that converts a number to binary, by returning a list of bits. Let's snoop on it by adding the `@pysnooper.snoop()` decorator:\n\n```python\nimport pysnooper\n\n@pysnooper.snoop()\ndef number_to_bits(number):\n    if number:\n        bits = []\n        while number:\n            number, remainder = divmod(number, 2)\n            bits.insert(0, remainder)\n        return bits\n    else:\n        return [0]\n\nnumber_to_bits(6)\n```\nThe output to stderr is:\n\n![](https:\u002F\u002Fi.imgur.com\u002FTrF3VVj.jpg)\n\nOr if you don't want to trace an entire function, you can wrap the relevant part in a `with` block:\n\n```python\nimport pysnooper\nimport random\n\ndef foo():\n    lst = []\n    for i in range(10):\n        lst.append(random.randrange(1, 1000))\n\n    with pysnooper.snoop():\n        lower = min(lst)\n        upper = max(lst)\n        mid = (lower + upper) \u002F 2\n        print(lower, mid, upper)\n\nfoo()\n```\n\nwhich outputs something like:\n\n```\nNew var:....... i = 9\nNew var:....... lst = [681, 267, 74, 832, 284, 678, ...]\n09:37:35.881721 line        10         lower = min(lst)\nNew var:....... lower = 74\n09:37:35.882137 line        11         upper = max(lst)\nNew var:....... upper = 832\n09:37:35.882304 line        12         mid = (lower + upper) \u002F 2\n74 453.0 832\nNew var:....... mid = 453.0\n09:37:35.882486 line        13         print(lower, mid, upper)\nElapsed time: 00:00:00.000344\n```\n\n## Features\n\nIf stderr is not easily accessible for you, you can redirect the output to a file:\n\n```python\n@pysnooper.snoop('\u002Fmy\u002Flog\u002Ffile.log')\n```\n\nYou can also pass a stream or a callable instead, and they'll be used.\n\nSee values of some expressions that aren't local variables:\n\n```python\n@pysnooper.snoop(watch=('foo.bar', 'self.x[\"whatever\"]'))\n```\n\nShow snoop lines for functions that your function calls:\n\n```python\n@pysnooper.snoop(depth=2)\n```\n\n**See [Advanced Usage](https:\u002F\u002Fgithub.com\u002Fcool-RR\u002FPySnooper\u002Fblob\u002Fmaster\u002FADVANCED_USAGE.md) for more options.** \u003C------\n\n\n## Installation with Pip\n\nThe best way to install **PySnooper** is with Pip:\n\n```console\n$ pip install pysnooper\n```\n\n## Other installation options\n\nConda with conda-forge channel:\n\n```console\n$ conda install -c conda-forge pysnooper\n```\n\nArch Linux:\n\n```console\n$ yay -S python-pysnooper\n```\n\nFedora Linux:\n\n```console\n$ dnf install python3-pysnooper\n```\n\n\n## Citing PySnooper\n\nIf you use PySnooper in academic work, please use this citation format:\n\n```bibtex\n@software{rachum2019pysnooper,\n    title={PySnooper: Never use print for debugging again},\n    author={Rachum, Ram and Hall, Alex and Yanokura, Iori and others},\n    year={2019},\n    month={jun},\n    publisher={PyCon Israel},\n    doi={10.5281\u002Fzenodo.10462459},\n    url={https:\u002F\u002Fgithub.com\u002Fcool-RR\u002FPySnooper}\n}\n```\n\n\n## License\n\nCopyright (c) 2019 Ram Rachum and collaborators, released under the MIT license.\n\n\n## Media Coverage\n\n[Hacker News thread](https:\u002F\u002Fnews.ycombinator.com\u002Fitem?id=19717786)\nand [\u002Fr\u002FPython Reddit thread](https:\u002F\u002Fwww.reddit.com\u002Fr\u002FPython\u002Fcomments\u002Fbg0ida\u002Fpysnooper_never_use_print_for_debugging_again\u002F) (22 April 2019)\n","PySnooper 是一个轻量级的 Python 调试工具，旨在替代传统的 print 语句进行调试。通过在函数前添加一个装饰器，用户可以轻松获取该函数执行过程中的详细日志，包括每行代码的执行情况以及局部变量的变化。其核心功能在于无需复杂的设置即可快速启用，并且支持将输出重定向到文件或自定义流中，同时还可以监控特定表达式的值。特别适合于需要快速定位问题但又不想配置复杂调试环境的开发场景，或是用于难以直接访问 stderr 的情况下。",2,"2026-06-11 02:50:59","top_language"]