How to check if an object start with a specific package:
module = inspect.getmodule(o) is_foo_app: bool = False if module and module.__name__: if module.__name__.split('.')[0] == "foo_app": is_foo_app = True |
Retrieve all members of an object:
getmembers: list[tuple[str, Any]] = inspect.getmembers(foo_object) list_members = [str(t) for t in getmembers] join = '\n'.join(list_members) print(f'join={join}') |
Retrieve all methods of an object:
getmembers: list[tuple[str, Any]] = inspect.getmembers(foo_object, predicate=inspect.ismethod) list_methods = [str(t) for t .in getmembers] join = '\n'.join(list_methods) print(f'join={join}') |