Why can not I inspect the source code of the __builtins__
module?
>>> import inspect
>>> inspect.getsource(__builtins__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/inspect.py", line 701, in getsource
lines, lnum = getsourcelines(object)
File "/usr/lib/python2.7/inspect.py", line 690, in getsourcelines
lines, lnum = findsource(object)
File "/usr/lib/python2.7/inspect.py", line 526, in findsource
file = getfile(object)
File "/usr/lib/python2.7/inspect.py", line 403, in getfile
raise TypeError('{!r} is a built-in module'.format(object))
TypeError: <module '__builtin__' (built-in)> is a built-in module
I went through this talk but it did not help.
This should not happen, if I interpret this well:
>>> help(inspect.getsource)
Help on function getsource in module inspect:
getsource(object)
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.
Is there a way to overcome this other than browsing the Python GitHub repository as described here and there.