Created
May 13, 2020 22:54
-
-
Save amirgon/fb27edc4265dfdbb2203938a30e4ca95 to your computer and use it in GitHub Desktop.
Micropython module inspection
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 types import ModuleType | |
def inspect(t, name=None, nesting=0): | |
if not (name or hasattr(t, "__name__")): return | |
print("| "*nesting + (name if name else t.__name__)) | |
if isinstance(t, int) or isinstance(t, str): return | |
if t is type or isinstance(lv, ModuleType): | |
for x in dir(t): | |
if not x.startswith("__"): | |
inspect(getattr(t,x), name=x, nesting = nesting + 1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment