[Tutor] Recreating the help module

M Nickey mnickey at gmail.com
Wed Jul 25 07:19:59 CEST 2012


Hey all,

I'm trying to recreate the 'help' on various modules that are available. So far, I have a bit of code and it seems to be working for the most part. I can get the modules available but I also want to be able to print the information that is available for each module.

Current output:
['__add__', '__class__', '__contains__', ... 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
str(object) -> string

Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

Desired result:
['__add__', '__class__', '__contains__', ... 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']

atof(s):
Return the floating point number represented by the st
atof(s) -> float

I'm close (I think) but I just can figure out how to grab that part of the documentation. Any advice?


Code:
import os
import string
import inspect

def getDirName():
    modList = []
    manPage = 'string'       #used as a place holder for now...           
    cwd = dir(manPage)
    print cwd
    info = inspect.getdoc(cwd[35])          
    print info
    return

if __name__ == '__main__':
    getDirName()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120724/12a4b67d/attachment.html>


More information about the Tutor mailing list