ID EN
Inspect

getsource

Python 3.11

Return the text of the source code for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a single string. An OSError is raised if the source code cannot be retrieved. A TypeError is raised if the object is a built-in module, class, or function.

Syntax

PYTHON
inspect.getsource(object)

See Also

OSError TypeError OSError IOError