The following code prints each function's docstring from an imported module. However, the results incude some functions that were not defined within the module, but rather, were imported by the module.
import inspect
import my_module
all_functions = inspect.getmembers(my_module, inspect.isfunction)
for i in all_functions:
print i[0] # print function name
print i[1].__doc__ # print docstring
How can I print only the docstrings of functions defined within the module?