printing class methods
jason at jorendorff.com
Fri Jan 25 06:28:36 CET 2002
> sorry, just as I saw my mail disappear I remebered -
> dir(class_or_module_name), but the second question still stands - Is there
> a way to find out the number and type of arguments?
Arguments aren't typed.
The "inspect" module will help you find the number and names
for name in dir(MyClass):
method = getattr(MyClass, name)
# methods aren't exactly the same thing as functions,
# so you get a method, you have to grab it's "im_func"
# attribute to get at the underlying function.
method = method.im_func
print name, inspect.getargspec(method)
## Jason Orendorff http://www.jorendorff.com/
More information about the Python-list