def callAllMethods(obj: object) -> List[Tuple[str, Any]]:
results = [] # type: List[Tuple[str, Any]]
for method in dir(obj):
if method == '__hash__':
continue
if callable(getattr(obj, method)):
try:
res = getattr(obj, method)()
if isinstance(res, bool) or isinstance(res, int):
results.append((method, res))
if isinstance(res, str):
# Ignore anything with 0x in it since memory addresses change
if '0x' not in res:
results.append((method, res))
except:
if '0x' not in method:
results.append(('except', method))
return results
评论列表
文章目录