Last active
October 23, 2020 14:03
-
-
Save JanPhKoch/2fa6059aec02fa85777ff5c7eb6f399f to your computer and use it in GitHub Desktop.
Print list of subclasses and their docstrings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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