builtins — Built-in objects


This module provides direct access to all ‘built-in’ identifiers of Python; forexample,builtins.open is the full name for the built-in functionopen().

This module is not normally accessed explicitly by most applications, but can beuseful in modules that provide objects with the same name as a built-in value,but in which the built-in of that name is also needed. For example, in a modulethat wants to implement anopen() function that wraps the built-inopen(), this module can be used directly:

importbuiltinsdefopen(path):f=builtins.open(path,'r')returnUpperCaser(f)classUpperCaser:'''Wrapper around a file that converts output to uppercase.'''def__init__(self,f):self._f=fdefread(self,count=-1):returnself._f.read(count).upper()# ...

As an implementation detail, most modules have the name__builtins__ madeavailable as part of their globals. The value of__builtins__ is normallyeither this module or the value of this module’s__dict__ attribute.Since this is an implementation detail, it may not be used by alternateimplementations of Python.