问题描述
我必须分析一个外部API的方法,以及我通常如何编写测试脚本,或者找一个示例代码,做一个
I have to analyze methods a foreign API, and how I usually do it it to write a test script, or find an example code, do a
ipdb.set_trace()
我想在哪里试验,而不是拿查看当前可用的变量,对象及其方法。但是,当我想以Ipython提供的方式检查文档时
Where I want to experiment, and than take a look at currently available variables, objects and their methods. However, when I want to check the documentation the way Ipython offers
object.method?
我得到
*** SyntaxError: invalid syntax (<stdin>, line 1)
如果我尝试
If I try
help(object.method)
它给出了
*** No help on (object.method)
这是否意味着所选方法没有文档,或者我使用错误的方法调用它?
Does that mean that there is no documentation for the selected method, or am I using the wrong way of calling it?
推荐答案
help()
函数实际上是 pydoc.help()
的包装器,这意味着您可以执行以下操作:
The help()
function is actually a wrapper around pydoc.help()
which means that you can do something like:
ipdb> import math
ipdb> import pydoc
ipdb> pydoc.help(math.log)
这篇关于Ipdb和方法文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!