How can I list the methods in a Python 2.5 module?

Evan Kroske picture Evan Kroske · Aug 15, 2009 · Viewed 39.7k times · Source

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?

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

Answer

Alexander Ljungberg picture Alexander Ljungberg · Aug 15, 2009

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