11.. XXX document all delegations to __special__ methods
22 .. _built-in-funcs :
33
4- Built-in Functions
4+ Built-in functions
55==================
66
77The Python interpreter has a number of functions and types built into it that
@@ -129,7 +129,7 @@ are always available. They are listed here in alphabetical order.
129129 anext(async_iterator, default, /)
130130
131131 When awaited, return the next item from the given :term: `asynchronous
132- iterator `, or *default * if given and the iterator is exhausted.
132+ iterator `, or *default * if given and the iterator is :term: ` exhausted ` .
133133
134134 This is the async variant of the :func: `next ` builtin, and behaves
135135 similarly.
@@ -1223,7 +1223,7 @@ are always available. They are listed here in alphabetical order.
12231223 process_block(block)
12241224
12251225 *stop_exception * is useful for callables
1226- which report exhaustion by raising an exception
1226+ which report :term: ` exhaustion <exhausted> ` by raising an exception
12271227 instead of returning a special value.
12281228 For example, draining a queue::
12291229
@@ -1315,7 +1315,7 @@ are always available. They are listed here in alphabetical order.
13151315 yielding the results. If additional *iterables * arguments are passed,
13161316 *function * must take that many arguments and is applied to the items from all
13171317 iterables in parallel. With multiple iterables, the iterator stops when the
1318- shortest iterable is exhausted. If *strict * is ``True `` and one of the
1318+ shortest iterable is :term: ` exhausted ` . If *strict * is ``True `` and one of the
13191319 iterables is exhausted before the others, a :exc: `ValueError ` is raised. For
13201320 cases where the function inputs are already arranged into argument tuples,
13211321 see :func: `itertools.starmap `.
@@ -1397,7 +1397,7 @@ are always available. They are listed here in alphabetical order.
13971397
13981398 Retrieve the next item from the :term: `iterator ` by calling its
13991399 :meth: `~iterator.__next__ ` method. If *default * is given, it is returned
1400- if the iterator is exhausted, otherwise :exc: `StopIteration ` is raised.
1400+ if the iterator is :term: ` exhausted ` , otherwise :exc: `StopIteration ` is raised.
14011401
14021402
14031403.. class :: object()
@@ -1459,7 +1459,8 @@ are always available. They are listed here in alphabetical order.
14591459 already exists), ``'x' `` for exclusive creation, and ``'a' `` for appending
14601460 (which on *some * Unix systems, means that *all * writes append to the end of
14611461 the file regardless of the current seek position). In text mode, if
1462- *encoding * is not specified the encoding used is platform-dependent:
1462+ *encoding * is not specified, UTF-8 is used by default; if
1463+ :ref: `Python UTF-8 Mode <utf8-mode >` is disabled,
14631464 :func: `locale.getencoding ` is called to get the current locale encoding.
14641465 (For reading and writing raw bytes use binary mode and leave
14651466 *encoding * unspecified.) The available modes are:
@@ -1490,7 +1491,7 @@ are always available. They are listed here in alphabetical order.
14901491 argument) return contents as :class: `bytes ` objects without any decoding. In
14911492 text mode (the default, or when ``'t' `` is included in the *mode * argument),
14921493 the contents of the file are returned as :class: `str `, the bytes having been
1493- first decoded using a platform-dependent encoding or using the specified
1494+ first decoded using the default encoding or using the specified
14941495 *encoding * if given.
14951496
14961497 .. note ::
@@ -1519,9 +1520,11 @@ are always available. They are listed here in alphabetical order.
15191520 described above for binary files.
15201521
15211522 *encoding * is the name of the encoding used to decode or encode the file.
1522- This should only be used in text mode. The default encoding is platform
1523- dependent (whatever :func: `locale.getencoding ` returns), but any
1524- :term: `text encoding ` supported by Python can be used.
1523+ This should only be used in text mode. The default encoding is UTF-8;
1524+ if :ref: `Python UTF-8 Mode <utf8-mode >` is disabled, the default is
1525+ platform-dependent (whatever :func: `locale.getencoding ` returns).
1526+ Any :term: `text encoding ` supported by Python can be used, and
1527+ ``encoding="locale" `` specifies the current locale encoding explicitly.
15251528 See the :mod: `codecs ` module for the list of supported encodings.
15261529
15271530 *errors * is an optional string that specifies how encoding and decoding
@@ -1638,6 +1641,10 @@ are always available. They are listed here in alphabetical order.
16381641 .. versionchanged :: 3.11
16391642 The ``'U' `` mode has been removed.
16401643
1644+ .. versionchanged :: 3.15
1645+ UTF-8 is now the default encoding, instead of the
1646+ platform-dependent locale encoding (:pep: `686 `).
1647+
16411648.. function :: ord(character, /)
16421649
16431650 Return the ordinal value of a character.
@@ -2312,7 +2319,7 @@ are always available. They are listed here in alphabetical order.
23122319 the code that prepared these iterables. Python offers three different
23132320 approaches to dealing with this issue:
23142321
2315- * By default, :func: `zip ` stops when the shortest iterable is exhausted.
2322+ * By default, :func: `zip ` stops when the shortest iterable is :term: ` exhausted ` .
23162323 It will ignore the remaining items in the longer iterables, cutting off
23172324 the result to the length of the shortest iterable::
23182325
@@ -2327,7 +2334,7 @@ are always available. They are listed here in alphabetical order.
23272334 [('a', 1), ('b', 2), ('c', 3)]
23282335
23292336 Unlike the default behavior, it raises a :exc: `ValueError ` if one iterable
2330- is exhausted before the others:
2337+ is :term: ` exhausted ` before the others:
23312338
23322339 >>> for item in zip (range (3 ), [' fee' , ' fi' , ' fo' , ' fum' ], strict = True ): # doctest: +SKIP
23332340 ... print (item)
0 commit comments