Where is the built-in module located?

I tried to find in all the directories listed in sys.path, but I could not find the file builtins.py, so where is it?

+4
source share
1 answer

Literally, the module is built into the python interpreter.

>>> import builtins
>>> builtins
<module 'builtins' (built-in)>
>>> import sys
>>> sys
<module 'sys' (built-in)>

Such modules are presented (built-in), as you can see in the previous interactive session.

If the module is loaded from a file, it will be presented as follows:

>>> import ftplib
>>> ftplib
<module 'ftplib' from 'C:\\Python34\\lib\\ftplib.py'>

The UPDATE . You can find the built-in module code in Python/bltinmodule.cfrom the Python source code.

+4
source

All Articles