Movatterモバイル変換


[0]ホーム

URL:


Navigation

28.3.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(). SeeBuilt-in Functions andBuilt-in Constants fordocumentation.

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 upper-case.'''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.

Previous topic

28.2.sysconfig — Provide access to Python’s configuration information

Next topic

28.4.__main__ — Top-level script environment

This Page

Quick search

Enter search terms or a module, class or function name.

Navigation

©Copyright 1990-2017, Python Software Foundation.
The Python Software Foundation is a non-profit corporation.Please donate.
Last updated on Sep 19, 2017.Found a bug?
Created usingSphinx 1.2.

[8]ページ先頭

©2009-2025 Movatter.jp