从print切换到debugger(),永远不要回头!
print-considered-harmful的Python项目详细描述
从print切换到debugger(),永远不要回头。
import debug debugger() # <-- breaks here
在主文件中导入此模块以将debugger作为内置项添加 命令。
文档
所有功能
debugger() debugger.enable() debugger.disable() debug.wrap(function) debug.sample(function) function.samples
调用debugger将打开ipdb调试器,
import debug debugger() # <-- breaks here
从ipdb提示符调用debugger.disable将禁用所有 断点,
import debug debugger() # <-- breaks here # >> debugger.disable() # >> continue debugger() # <-- does not break here
使用debug.wrap设置函数断点,
def fun(): pass def example(): fun() fun = debug.wrap(fun) example() # <-- breaks above at definition of fun
使用debug.sample收集函数参数,
def fun(a, b=None): return fun = debug.sample(fun) fun(23) fun(42, 'hello worlds') debugger() # <-- breaks here # >> len(fun.samples) # 2 # >> fun.samples # [{0: 23, '$': 529}, {0: 42, 'b': 'hello worlds', '$': 1764}]
使用debug.log收集值,
for each in range(3): debug.log(each) debugger() # <-- breaks here # >> debugger.logs # {'example.py': {2: [0, 1, 2]}}
安装
要安装此软件包,请运行
pip install print-considered-harmful
贡献
欢迎在Github上提交错误报告和请求, https://github.com/akuhn/print-considered-harmful