从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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
爪哇太阳报。安全验证器。ValidatorException:PKIX路径生成失败   java理解为什么在onDispatchTouchEvent()返回True后仍调用onClick()   java如何在资源包中使用JSF标记/如何在资源包中重写URL?   java什么是流控制异常的替代方案?   java使用Spring数据JPA/MongoDB交叉存储,一个查询可以跨越两个数据库吗?   Apache Sling/felix中的java OSGi slf4j日志记录   为什么当我们想要水平/垂直旋转矩阵时,我们要把这个项除以2?   尝试从外部网页接收JSON字符串时出现安卓 Java NullPointerException   java执行异常:从Callable调用方法时   java在jetty上以调试模式运行webapp,使用maven jetty插件在intellij中构建成功(应用程序应在调试模式下启动)   带有内存数据库的linux Java应用程序的构建时间太长   基于java的随机数单元测试算法   java类型javax。摆动JComponent无法解析   Google日历API和UI小部件Java   java tomcat没有突然和任意地响应   java无法使用jsoup在html中获取图像src   我无法让Java接受键盘输入字符串   java如何开始使用Bambol而不让部署永远继续?   java如何使用另一个类的actionPerformed方法删除一个类/组件中的按钮?   java JSON反序列化brakets{}中的一系列对象