如何在Python 2.5模块中列出方法? [英] How can I list the methods in a Python 2.5 module?

查看:67
本文介绍了如何在Python 2.5模块中列出方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C语言编写的Python库,该库没有任何类型的文档.我想使用自省功能,至少查看模块中有哪些方法和类.是否有人可以使用某个函数或库来列出模块中的函数(带有参数列表)和类(带有方法和成员变量)?

I'm trying to use a Python library written in C that has no documentation of any kind. I want to use introspection to at least see what methods and classes are in the modules. Does somebody have a function or library I can use to list the functions (with argument lists) and classes (with methods and member variables) within a module?

我发现本文有关Python内省的信息,但我很确定它没有不适用于Python 2.5.感谢您的帮助.

I found this article about Python introspection, but I'm pretty sure it doesn't apply to Python 2.5. Thanks for the help.

推荐答案

以下是您至少可以做的一些事情:

Here are some things you can do at least:

import module

print dir(module) # Find functions of interest.

# For each function of interest:
help(module.interesting_function)
print module.interesting_function.func_defaults

这篇关于如何在Python 2.5模块中列出方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆