| 1 |
## 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__ |