为Python提供轻松的调试和检查
项目描述
ShowMe – Python的快速简单调试
ShowMe是一组简单的Python函数装饰器,非常实用。它允许您查看跟踪信息、执行时间、CPU时间以及函数文档。
安装
要使用showme,只需
pip install showme
或者,如果您必须
easy_install showme
使用方法
打印传入的参数和函数调用。
@showme.trace def complex_function(a, b, c, **kwargs): >>> complex_function('alpha', 'beta', False, debug=True) calling haystack.submodule.complex_function() with args: ({'a': 'alpha', 'b': 'beta', 'c': False},) kwargs: {'debug': True}
打印函数执行时间。
@showme.cputime def complex_function(a, b, c): >>> complex_function() 3 function calls in 0.013 CPU seconds ncalls tottime percall cumtime percall filename:lineno(function) 1 0.013 0.013 0.013 0.013 test_time.py:6(test) 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 1 0.000 0.000 0.000 0.000 {range}
美观打印函数文档。
@showme.docs def complex_function(): """Example Documentation for complex_function""" pass >>> complex_function() Example Documentation for complex_function
历史
1.0.0 (2010-09-05)
功能集完整
showme对PyPi的公共发布
项目清理(删除全局/局部变量)
0.0.5 (2010-09-05)
支持@showme.time(简单但重要功能)
添加彩色输出(通过Colorama提供)
0.0.4 (2010-09-04)
编写史诗级的@showme.trace装饰器
支持@showme.docs
0.0.3 (2010-09-01)
设置一般配置
支持@showme.cputime
装饰器装饰器的供应商化