| 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 |
nino.borges |
744 |
print("\n".join(["%s %s" %
|
| 13 |
ninoborges |
8 |
(method.ljust(spacing),
|
| 14 |
|
|
processFunc(str(getattr(object, method).__doc__)))
|
| 15 |
nino.borges |
744 |
for method in methodList]))
|
| 16 |
ninoborges |
8 |
if __name__ == "__main__":
|
| 17 |
nino.borges |
744 |
print(help.__doc__) |