Like we have python modules in the standard library from which we can import methods and use them, is there also a module where all the built-in functions are defined? If yes, how can I view that module?
Asked
Active
Viewed 2,642 times
4
-
2Did you try googling [Python built-in function module](https://www.google.com/search?q=python+built-in+function+module)? – user2357112 Sep 01 '17 at 16:41
-
I wanted to know from where I could view the contents of 'builtins' module...i.e. the exact code. – Rishu Sep 02 '17 at 18:17
-
1https://stackoverflow.com/questions/40851872/how-can-i-see-pythons-builtins-source-code/40851954#40851954 – user2357112 Sep 02 '17 at 18:21
-
thanks @user2357112 – Rishu Sep 03 '17 at 19:20
-
btw why are those not '.py' modules, but, C source code files? – Rishu Sep 03 '17 at 19:27
-
1Because they're not written in Python. They're C. Not all of the CPython implementation is written in Python. – user2357112 Sep 03 '17 at 19:37
2 Answers
0
On python3, import builtins
or import __builtin__
for older versions
You can check any modules content with the dir
function

JBernardo
- 32,262
- 10
- 90
- 115
0
The builtins
(Python 3) or __builtin__
(Python 2) module provides access to them.
This is even useful sometimes if you rebind the name of a builtin, eg list = [1, 2, 3]
. You generally shouldn't do that, but if you do you can still access the builtin list constructor as builtins.list
.

Peter DeGlopper
- 36,326
- 7
- 90
- 83
-
-
Does there exists a module such as 'builtins.py' ? If yes, where is it located in the python directory? – Rishu Sep 02 '17 at 18:15