Eva*_*ske 26 python introspection python-2.5
我正在尝试使用用C编写的Python库,它没有任何文档.我想使用内省来至少看看模块中有哪些方法和类.有人有一个函数或库我可以用来列出模块中的函数(带参数列表)和类(带方法和成员变量)吗?
Ale*_*erg 56
以下是您至少可以做的一些事情:
import module
print dir(module) # Find functions of interest.
# For each function of interest:
help(module.interesting_function)
print module.interesting_function.func_defaults
Run Code Online (Sandbox Code Playgroud)
这也很不错:
import module
help(module)
Run Code Online (Sandbox Code Playgroud)
它将打印模块的docstring,然后列出模块的内容,也打印他们的文档字符串.
| 归档时间: |
|
| 查看次数: |
36213 次 |
| 最近记录: |