Hi all,

I am testing a somewhat large module, and I would like to automate the testing of the documentation (I know, I could just look at the code, but I wanted to make sure *and* the question became a cool one :cheesy:)

Here's the basic idea:

for i in dir(MyClass):
    if not i.startswith("__"):
        help(MyClass.i)

which code fails because i is not a member function of MyClass! :p What's the right way to do this?

Thanks,
Jeff Cagle

Got it. Hooray for Google:

for i in dir(MyClass):
    if not i.startswith("__"):
        help(eval("MyClass."+i))

slight improvement:

for i in dir(MyClass):
    if not i.startswith("__") and callable(eval("MyClass."+i)):
        help(eval("MyClass."+i))

I found that the former would occasionally dump me into the interactive help! :lol:

Another variation:

# using __doc__
for method in dir(MyClass):
    obj = eval("MyClass."+method)
    if not method.startswith("__") and callable(obj):
        print "method %s:" % method
        print obj.__doc__
This question has already been answered. Start a new discussion instead.