Python inspect Module
Example
Verify that function signature support is present:
import inspect
print(hasattr(inspect, "signature"))
Try it Yourself »
Definition and Usage
The inspect module provides several useful functions to help get information about live objects such as modules, classes, methods, functions, tracebacks, frame objects, and code objects.
Use it to retrieve source code, function signatures, parameters, and to examine the runtime stack for debugging and tooling.
Members
Member | Description |
---|---|
getdoc() | Get the documentation string for an object. |
getfile() | Return the name of the file in which an object was defined. |
getfullargspec() | Get the names and default values of a callable's parameters. |
getmembers() | Return all members of an object as (name, value) pairs. |
getsource() | Return the text of the source code for an object. |
isbuiltin() | Return True if the object is a built-in function or method. |
isclass() | Return True if the object is a class. |
iscoroutine() | Return True if the object is a coroutine. |
isfunction() | Return True if the object is a Python function. |
isgenerator() | Return True if the object is a generator. |
ismethod() | Return True if the object is a bound method. |
ismodule() | Return True if the object is a module. |
signature() | Get a Signature object for a callable to inspect its parameters. |