Mar-10-2022, 09:44 AM
import sys from importlib import import_module from inspect import isclass, isfunction if len(sys.argv) != 2: raise SystemExit("Module name is required") def get_functions(module, private=False): module = import_module(module) functions = [] classes = [] for name, object in vars(module).items(): if not private and name.startswith("_"): continue if isfunction(object): functions.append(name) elif isclass(object): classes.append(name) return functions, classes if __name__ == "__main__": functions, classes = get_functions(sys.argv[1]) indent = " " * 4 print() print("Functions:") for func in functions: print(indent, func) print() print("Classes:") for cls in classes: print(indent, cls) print()
Output:[andre@andre-Fujitsu-i5 ~]$ python scan_func.py pathlib
Functions:
urlquote_from_bytes
Classes:
Sequence
attrgetter
PurePath
PurePosixPath
PureWindowsPath
Path
PosixPath
WindowsPath
Here you find more functions, to inspect the code: https://docs.python.org/3/library/inspect.html
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!