0

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

2
Contributors
4
Replies
5
Views
11 Years
Discussion Span
Last Post by vegaseat
0

Got it. Hooray for Google:

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

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:

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.