Builtins

8. Builtins#

import builtins

We can see what all builtins does Python provide.

For our sake, we are traversing the complete list and printing the number and builtin attribute.

The function we are using to traverse in dir(builtins) and get index and builtin attribute is enumerate which is also a bulitin πŸ˜‰

for index, builtin_attribute in enumerate(dir(builtins)):
    print(f"{index}) {builtin_attribute}")
0) ArithmeticError
1) AssertionError
2) AttributeError
3) BaseException
4) BaseExceptionGroup
5) BlockingIOError
6) BrokenPipeError
7) BufferError
8) BytesWarning
9) ChildProcessError
10) ConnectionAbortedError
11) ConnectionError
12) ConnectionRefusedError
13) ConnectionResetError
14) DeprecationWarning
15) EOFError
16) Ellipsis
17) EncodingWarning
18) EnvironmentError
19) Exception
20) ExceptionGroup
21) False
22) FileExistsError
23) FileNotFoundError
24) FloatingPointError
25) FutureWarning
26) GeneratorExit
27) IOError
28) ImportError
29) ImportWarning
30) IndentationError
31) IndexError
32) InterruptedError
33) IsADirectoryError
34) KeyError
35) KeyboardInterrupt
36) LookupError
37) MemoryError
38) ModuleNotFoundError
39) NameError
40) None
41) NotADirectoryError
42) NotImplemented
43) NotImplementedError
44) OSError
45) OverflowError
46) PendingDeprecationWarning
47) PermissionError
48) ProcessLookupError
49) RecursionError
50) ReferenceError
51) ResourceWarning
52) RuntimeError
53) RuntimeWarning
54) StopAsyncIteration
55) StopIteration
56) SyntaxError
57) SyntaxWarning
58) SystemError
59) SystemExit
60) TabError
61) TimeoutError
62) True
63) TypeError
64) UnboundLocalError
65) UnicodeDecodeError
66) UnicodeEncodeError
67) UnicodeError
68) UnicodeTranslateError
69) UnicodeWarning
70) UserWarning
71) ValueError
72) Warning
73) ZeroDivisionError
74) __IPYTHON__
75) __build_class__
76) __debug__
77) __doc__
78) __import__
79) __loader__
80) __name__
81) __package__
82) __spec__
83) abs
84) aiter
85) all
86) anext
87) any
88) ascii
89) bin
90) bool
91) breakpoint
92) bytearray
93) bytes
94) callable
95) chr
96) classmethod
97) compile
98) complex
99) copyright
100) credits
101) delattr
102) dict
103) dir
104) display
105) divmod
106) enumerate
107) eval
108) exec
109) execfile
110) filter
111) float
112) format
113) frozenset
114) get_ipython
115) getattr
116) globals
117) hasattr
118) hash
119) help
120) hex
121) id
122) input
123) int
124) isinstance
125) issubclass
126) iter
127) len
128) license
129) list
130) locals
131) map
132) max
133) memoryview
134) min
135) next
136) object
137) oct
138) open
139) ord
140) pow
141) print
142) property
143) range
144) repr
145) reversed
146) round
147) runfile
148) set
149) setattr
150) slice
151) sorted
152) staticmethod
153) str
154) sum
155) super
156) tuple
157) type
158) vars
159) zip

There’s a difference between Keywords and Builtins πŸ€”. We can’t assign a new object to the Keywords, if we try to do, we would be seeing an exception raised πŸ”΄. But coming to builtins, we can assign any object to the builtin names, and Python won’t have any issues, but it’s not a good practice to do so πŸ˜‡