Entry
Getting doc strings from module
Jul 5th, 2000 10:00
Nathan Wallace, Hans Nowak, Snippet 130, Thomas A. Bryan
"""
Packages: text.docstrings
"""
"""
If you're playing in the interpreter, learn to use the doc strings
for the modules that have them:
>>> print os.system.__doc__
system(command) -> exit_status
Execute the command (a string) in a subshell.
>>> print os.popen.__doc__
popen(command [, mode='r' [, bufsize]]) -> pipe
Open a pipe to/from a command returning a file object.
To find out what's available, do a dir(os).
You may also want to read through/download the library reference from
www.python.org
Here's a handy function...you'll probably want to modify it so that
it writes to a file unless you have a lot of "history" on your terminal
window.
"""
def get_docs(modulename):
for el in dir(eval(modulename)):
try:
print el
exec('print %s.%s.__doc__' % (modulename,el))
except: #catch all exceptions
print '%s has no __doc__' % el
#for example
import string
get_docs('string')