MCPcopy Index your code
hub / github.com/python/cpython / getsource

Function getsource

Lib/inspect.py:1179–1186  ·  view source on GitHub ↗

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.

(object)

Source from the content-addressed store, hash-verified

1177 return getblock(lines[lnum:]), lnum + 1
1178
1179def getsource(object):
1180 """Return the text of the source code for an object.
1181
1182 The argument may be a module, class, method, function, traceback, frame,
1183 or code object. The source code is returned as a single string. An
1184 OSError is raised if the source code cannot be retrieved."""
1185 lines, lnum = getsourcelines(object)
1186 return ''.join(lines)
1187
1188# --------------------------------------------------- class tree extraction
1189def walktree(classes, children, parent):

Callers 1

_mainFunction · 0.85

Calls 2

getsourcelinesFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…