28.3. __builtin__ — Built-in objects

This module provides direct access to all ‘built-in’ identifiers of Python; for example, __builtin__.open is the full name for the built-in function open(). See Funções Built-in and Constantes Built-in for documentation.

Este módulo normalmente não é acessado explicitamente pela maioria dos aplicativos, mas pode ser útil em módulos que fornecem objetos com o mesmo nome como um valor embutido, mas em que o objeto embutido desse nome também é necessário. Por exemplo, em um módulo que deseja implementar uma função: func: open que envolve o embutido: func:` open`, este módulo pode ser usado diretamente

import __builtin__

def open(path):
    f = __builtin__.open(path, 'r')
    return UpperCaser(f)

class UpperCaser:
    '''Wrapper around a file that converts output to upper-case.'''

    def __init__(self, f):
        self._f = f

    def read(self, count=-1):
        return self._f.read(count).upper()

    # ...

CPython implementation detail: Most modules have the name __builtins__ (note the 's') made available as part of their globals. The value of __builtins__ is normally either this module or the value of this modules’s __dict__ attribute. Since this is an implementation detail, it may not be used by alternate implementations of Python.