ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Tool_Box/py2bkp/apihelper.py.bak
Revision: 744
Committed: Tue Apr 13 21:40:41 2021 UTC (4 years, 11 months ago) by nino.borges
Content type: application/x-trash
File size: 802 byte(s)
Log Message:
Updated all tools libs to be python 3 compatible. 

File Contents

# User Rev Content
1 nino.borges 744 ## 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__