Created
July 8, 2017 09:46
-
-
Save tfiers/fff73d1c496212db62536ffa0db8ff4d to your computer and use it in GitHub Desktop.
Inspect a python object when there is no documentation (or help(obj)) available.
This file contains 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
from pprint import pformat | |
from tabulate import tabulate | |
rows = [] | |
for name in dir(obj): | |
val = getattr(obj, name) | |
if callable(val): | |
try: | |
content = val() | |
except: | |
content = '/' | |
else: | |
content = val | |
rows.append((name, pformat(content))) | |
print(tabulate(rows)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment