Shane
Shane

Reputation: 1

Calling python help within a python script

I've a unique situation where I need to print out the help pages for all functions of a given imported module within a script and output it to a file.

import modx

for I in dir(modx):
    print help(modx.i)

Printing to stdout for now, will pipe to a file later once I figure out basic problem above.

Upvotes: 0

Views: 41

Answers (1)

Sarith Subramaniam
Sarith Subramaniam

Reputation: 246

I wrote this to print functions/classes within the itertools module. You can try with your module and check if it works:

#Replace itertools with your module
import itertools

#Replace items with iteritems in case of python 2.x
for name,item in itertools.__dict__.items():
    if callable(item):
        print("Name: ",name)
        print("*~*"*20)
        print(item.__doc__)
        print("*~*"*20,"\n")

Upvotes: 1

Related Questions