Can I get python to print the source code for __builtins__ directly?
OR (more preferably):
What is the pathname of the source code for __builtins__?
I at least know the following things:
__builtins__is a module, by typingtype(__builtins__).I have tried the best-answer-suggestions to a more general case of this SO question: "Finding the source code for built-in Python functions?". But no luck:
print inspect.getdoc(__builtins__)just gives me a description.inspect.getfile(__builtins__)just gives me an error:TypeError: <module '__builtin__' (built-in)> is a built-in modulehttps://hg.python.org/cpython/file/c6880edaf6f3/# does not seem to contain an entry for
__builtins__. I've tried "site:" search and browsed several of the directories but gave up after a few.
__builtins__name is an implementation detail, and__builtins__does not behave as consistently as you might expect. For example, it's not always a module! If you want to access the module where built-in names are defined, you shouldimport __builtin__(no s), orimport builtins(no underscores) on Python 3.