1:mod:`!builtins` --- Built-in objects 2===================================== 3 4.. module:: builtins 5 :synopsis: The module that provides the built-in namespace. 6 7-------------- 8 9This module provides direct access to all 'built-in' identifiers of Python; for 10example, ``builtins.open`` is the full name for the built-in function :func:`open`. 11 12This module is not normally accessed explicitly by most applications, but can be 13useful in modules that provide objects with the same name as a built-in value, 14but in which the built-in of that name is also needed. For example, in a module 15that wants to implement an :func:`open` function that wraps the built-in 16:func:`open`, this module can be used directly:: 17 18 import builtins 19 20 def open(path): 21 f = builtins.open(path, 'r') 22 return UpperCaser(f) 23 24 class UpperCaser: 25 '''Wrapper around a file that converts output to uppercase.''' 26 27 def __init__(self, f): 28 self._f = f 29 30 def read(self, count=-1): 31 return self._f.read(count).upper() 32 33 # ... 34 35As an implementation detail, most modules have the name ``__builtins__`` made 36available as part of their globals. The value of ``__builtins__`` is normally 37either this module or the value of this module's :attr:`~object.__dict__` attribute. 38Since this is an implementation detail, it may not be used by alternate 39implementations of Python. 40 41.. seealso:: 42 43 * :ref:`built-in-consts` 44 * :ref:`bltin-exceptions` 45 * :ref:`built-in-funcs` 46 * :ref:`bltin-types` 47