Question:
I’m looping through every attribute from a file and printing the attribute’s docstring. I only want to print the docstrings of functions/classes, though. How can I check if the attribute is a class or function?
from inspect import isClass
print(test.__doc__)
for attrName in dir(test):
attribute = getattr(test, attrName)
if callable(attribute) or isClass(attribute):
print(attribute.__doc__)