26.10.2 Retrieving source code
-
Get the documentation string for an object.
All tabs are expanded to spaces. To clean up docstrings that are
indented to line up with blocks of code, any whitespace than can be
uniformly removed from the second line onwards is removed.
-
Return in a single string any lines of comments immediately preceding
the object's source code (for a class, function, or method), or at the
top of the Python source file (if the object is a module).
-
Return the name of the (text or binary) file in which an object was
defined. This will fail with a TypeError if the object
is a built-in module, class, or function.
-
Try to guess which module an object was defined in.
-
Return the name of the Python source file in which an object was
defined. This will fail with a TypeError if the object
is a built-in module, class, or function.
-
Return a list of source lines and starting line number for an object.
The argument may be a module, class, method, function, traceback, frame,
or code object. The source code is returned as a list of the lines
corresponding to the object and the line number indicates where in the
original source file the first line of code was found. An
IOError is raised if the source code cannot be retrieved.
-
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
IOError is raised if the source code cannot be retrieved.
Release 2.5.4, documentation updated on 23rd December, 2008.
See About this document... for information on suggesting changes.