How to list all functions in a Python module?

I have a python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it.

I want to call the doc function on each one. In ruby I can do something like ClassName.methods to get a list of all the methods available on that class. Is there something similar in python?

eg. something like:

from somemodule import foo
print foo.methods # or whatever is the correct method to call

The inspect module. Also see the pydoc module, the help() function in the interactive interpreter and the pydoc command-line tool which generates the documentation you are after. You can just give them the class you wish to see the documentation of. They can also generate, for instance, HTML output and write it to disk.


You can use dir(module) to see all available methods/attributes. Also check out PyDocs.


Once you've import ed the module, you can just do:

 help(modulename)

... To get the docs on all the functions at once, interactively. Or you can use:

 dir(modulename)

... To simply list the names of all the functions and variables defined in the module.

链接地址: http://www.djcxy.com/p/26282.html

上一篇: 在Python中有多个构造函数的干净,pythonic方法是什么?

下一篇: 如何列出Python模块中的所有函数?