ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Tool_Box/apihelper.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
File size: 802 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8 ## apihelper.py
2     ## This program will take any object that has functions or methods (like a module, which has
3     ## functions, or a list, which has methods) and pints out the functions and their doc strings.
4     ## EBorges
5     ## 5.6.03
6    
7     def help(object, spacing=10, collapse=1):
8     """Print methods and doc strings.
9     Takes module, class, list, dictionary, or string."""
10     methodList = [method for method in dir(object) if callable(getattr(object, method))]
11     processFunc = collapse and (lambda s: " ".join(s.split())) or (lambda s: s)
12     print "\n".join(["%s %s" %
13     (method.ljust(spacing),
14     processFunc(str(getattr(object, method).__doc__)))
15     for method in methodList])
16     if __name__ == "__main__":
17     print help.__doc__