Skip to content

Instantly share code, notes, and snippets.

@JanPhKoch
Last active October 23, 2020 14:03
Show Gist options
  • Save JanPhKoch/2fa6059aec02fa85777ff5c7eb6f399f to your computer and use it in GitHub Desktop.
Save JanPhKoch/2fa6059aec02fa85777ff5c7eb6f399f to your computer and use it in GitHub Desktop.
Print list of subclasses and their docstrings
def buildObjectAndDocstring(pobject):
import inspect
objectListWithDocStrings = pobject.__name__ + ': ' + inspect.getdoc(pobject)
return objectListWithDocStrings
###################################################
############ test classes below ###################
class CheckBaseClass(object):pass
class CheckBla(CheckBaseClass):
"""DOCU"""
pass
class CheckBlu(CheckBaseClass):
"""DOCU 2"""
pass
class CheckBlub(CheckBaseClass):
""" docu 3"""
pass
############################################
# caller
for each in CheckBaseClass.__subclasses__():
print(buildObjectAndDocstring(each))
# CheckBla: DOCU
# CheckBlu: DOCU 2
# CheckBlub: docu 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment