Created
October 15, 2019 04:11
-
-
Save dvanic/93b1259b56ef9212418458fb66331d72 to your computer and use it in GitHub Desktop.
pythonGetObjectMethod
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 get_methods(object, spacing=20): | |
methodList = [] | |
for method_name in dir(object): | |
try: | |
if callable(getattr(object, method_name)): | |
methodList.append(str(method_name)) | |
except: | |
methodList.append(str(method_name)) | |
processFunc = (lambda s: ' '.join(s.split())) or (lambda s: s) | |
for method in methodList: | |
try: | |
print(str(method.ljust(spacing)) + ' ' + | |
processFunc(str(getattr(object, method).__doc__)[0:90])) | |
except: | |
print(method.ljust(spacing) + ' ' + ' getattr() failed') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment