Skip to content

Instantly share code, notes, and snippets.

@amirgon
Created May 13, 2020 22:54
Show Gist options
  • Save amirgon/fb27edc4265dfdbb2203938a30e4ca95 to your computer and use it in GitHub Desktop.
Save amirgon/fb27edc4265dfdbb2203938a30e4ca95 to your computer and use it in GitHub Desktop.
Micropython module inspection
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