August 2018
Intermediate to advanced
366 pages
10h 14m
English
For this recipe, the following steps are to be performed:
import inspect
def inspect_object(o):
if inspect.isfunction(o) or inspect.ismethod(o):
print('FUNCTION, arguments:', inspect.signature(o))
elif inspect.isclass(o):
print('CLASS, methods:', inspect.getmembers(o, inspect.isfunction))
else:
print('OBJECT ({}): {}'.format(
o.__class__,
[(n, v) for n, v in inspect.getmembers(o)
if not n.startswith('__')]
))
class MyClass: ...