summaryrefslogtreecommitdiff
path: root/devdocs/python~3.12/library%2Fbuiltins.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/python~3.12/library%2Fbuiltins.html
new repository
Diffstat (limited to 'devdocs/python~3.12/library%2Fbuiltins.html')
-rw-r--r--devdocs/python~3.12/library%2Fbuiltins.html22
1 files changed, 22 insertions, 0 deletions
diff --git a/devdocs/python~3.12/library%2Fbuiltins.html b/devdocs/python~3.12/library%2Fbuiltins.html
new file mode 100644
index 00000000..779799b3
--- /dev/null
+++ b/devdocs/python~3.12/library%2Fbuiltins.html
@@ -0,0 +1,22 @@
+ <span id="builtins-built-in-objects"></span><h1>builtins — Built-in objects</h1> <p>This module provides direct access to all ‘built-in’ identifiers of Python; for example, <code>builtins.open</code> is the full name for the built-in function <a class="reference internal" href="functions#open" title="open"><code>open()</code></a>. See <a class="reference internal" href="functions#built-in-funcs"><span class="std std-ref">Built-in Functions</span></a> and <a class="reference internal" href="constants#built-in-consts"><span class="std std-ref">Built-in Constants</span></a> for documentation.</p> <p>This module is not normally accessed explicitly by most applications, but can be useful 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 module that wants to implement an <a class="reference internal" href="functions#open" title="open"><code>open()</code></a> function that wraps the built-in <a class="reference internal" href="functions#open" title="open"><code>open()</code></a>, this module can be used directly:</p> <pre data-language="python">import builtins
+
+def open(path):
+ f = builtins.open(path, 'r')
+ return UpperCaser(f)
+
+class UpperCaser:
+ '''Wrapper around a file that converts output to uppercase.'''
+
+ def __init__(self, f):
+ self._f = f
+
+ def read(self, count=-1):
+ return self._f.read(count).upper()
+
+ # ...
+</pre> <p>As an implementation detail, most modules have the name <code>__builtins__</code> made available as part of their globals. The value of <code>__builtins__</code> is normally either this module or the value of this module’s <a class="reference internal" href="stdtypes#object.__dict__" title="object.__dict__"><code>__dict__</code></a> attribute. Since this is an implementation detail, it may not be used by alternate implementations of Python.</p> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2001&ndash;2023 Python Software Foundation<br>Licensed under the PSF License.<br>
+ <a href="https://docs.python.org/3.12/library/builtins.html" class="_attribution-link">https://docs.python.org/3.12/library/builtins.html</a>
+ </p>
+</div>