Python 3.13.8

This commit is contained in:
Thomas Wouters 2025-10-07 14:01:38 +02:00
parent cb4b09a2e1
commit a15ae614de
60 changed files with 872 additions and 336 deletions

View file

@ -1,4 +1,4 @@
# Autogenerated by Sphinx on Thu Aug 14 13:12:07 2025
# Autogenerated by Sphinx on Tue Oct 7 14:01:47 2025
# as part of the release process.
topics = {
@ -587,6 +587,9 @@ class instances.
Customizing module attribute access
===================================
module.__getattr__()
module.__dir__()
Special names "__getattr__" and "__dir__" can be also used to
customize access to module attributes. The "__getattr__" function at
the module level should accept one argument which is the name of an
@ -602,6 +605,8 @@ class instances.
present, this function overrides the standard "dir()" search on a
module.
module.__class__
For a more fine grained customization of the module behavior (setting
attributes, properties, etc.), one can set the "__class__" attribute
of a module object to a subclass of "types.ModuleType". For example:
@ -1037,12 +1042,33 @@ class and instance attributes applies as for regular assignments.
'bltin-ellipsis-object': r'''The Ellipsis Object
*******************
This object is commonly used by slicing (see Slicings). It supports
no special operations. There is exactly one ellipsis object, named
"Ellipsis" (a built-in name). "type(Ellipsis)()" produces the
"Ellipsis" singleton.
This object is commonly used used to indicate that something is
omitted. It supports no special operations. There is exactly one
ellipsis object, named "Ellipsis" (a built-in name).
"type(Ellipsis)()" produces the "Ellipsis" singleton.
It is written as "Ellipsis" or "...".
In typical use, "..." as the "Ellipsis" object appears in a few
different places, for instance:
* In type annotations, such as callable arguments or tuple elements.
* As the body of a function instead of a pass statement.
* In third-party libraries, such as Numpys slicing and striding.
Python also uses three dots in ways that are not "Ellipsis" objects,
for instance:
* Doctests "ELLIPSIS", as a pattern for missing content.
* The default Python prompt of the *interactive* shell when partial
input is incomplete.
Lastly, the Python documentation often uses three dots in conventional
English usage to mean omitted content, even in code examples that also
use them as the "Ellipsis".
''',
'bltin-null-object': r'''The Null Object
***************
@ -1859,15 +1885,29 @@ class attributes; they are shared by instances. Instance attributes
"except*" clause
----------------
The "except*" clause(s) are used for handling "ExceptionGroup"s. The
exception type for matching is interpreted as in the case of "except",
but in the case of exception groups we can have partial matches when
the type matches some of the exceptions in the group. This means that
multiple "except*" clauses can execute, each handling part of the
exception group. Each clause executes at most once and handles an
exception group of all matching exceptions. Each exception in the
group is handled by at most one "except*" clause, the first that
matches it.
The "except*" clause(s) specify one or more handlers for groups of
exceptions ("BaseExceptionGroup" instances). A "try" statement can
have either "except" or "except*" clauses, but not both. The exception
type for matching is mandatory in the case of "except*", so "except*:"
is a syntax error. The type is interpreted as in the case of "except",
but matching is performed on the exceptions contained in the group
that is being handled. An "TypeError" is raised if a matching type is
a subclass of "BaseExceptionGroup", because that would have ambiguous
semantics.
When an exception group is raised in the try block, each "except*"
clause splits (see "split()") it into the subgroups of matching and
non-matching exceptions. If the matching subgroup is not empty, it
becomes the handled exception (the value returned from
"sys.exception()") and assigned to the target of the "except*" clause
(if there is one). Then, the body of the "except*" clause executes. If
the non-matching subgroup is not empty, it is processed by the next
"except*" in the same manner. This continues until all exceptions in
the group have been matched, or the last "except*" clause has run.
After all "except*" clauses execute, the group of unhandled exceptions
is merged with any exceptions that were raised or re-raised from
within "except*" clauses. This merged exception group propagates on.:
>>> try:
... raise ExceptionGroup("eg",
@ -1880,20 +1920,19 @@ class attributes; they are shared by instances. Instance attributes
caught <class 'ExceptionGroup'> with nested (TypeError(2),)
caught <class 'ExceptionGroup'> with nested (OSError(3), OSError(4))
+ Exception Group Traceback (most recent call last):
| File "<stdin>", line 2, in <module>
| ExceptionGroup: eg
| File "<doctest default[0]>", line 2, in <module>
| raise ExceptionGroup("eg",
| [ValueError(1), TypeError(2), OSError(3), OSError(4)])
| ExceptionGroup: eg (1 sub-exception)
+-+---------------- 1 ----------------
| ValueError: 1
+------------------------------------
Any remaining exceptions that were not handled by any "except*" clause
are re-raised at the end, along with all exceptions that were raised
from within the "except*" clauses. If this list contains more than one
exception to reraise, they are combined into an exception group.
If the raised exception is not an exception group and its type matches
one of the "except*" clauses, it is caught and wrapped by an exception
group with an empty message string.
If the exception raised from the "try" block is not an exception group
and its type matches one of the "except*" clauses, it is caught and
wrapped by an exception group with an empty message string. This
ensures that the type of the target "e" is consistently
"BaseExceptionGroup":
>>> try:
... raise BlockingIOError
@ -1902,13 +1941,7 @@ class attributes; they are shared by instances. Instance attributes
...
ExceptionGroup('', (BlockingIOError()))
An "except*" clause must have a matching expression; it cannot be
"except*:". Furthermore, this expression cannot contain exception
group types, because that would have ambiguous semantics.
It is not possible to mix "except" and "except*" in the same "try".
The "break", "continue", and "return" statements cannot appear in an
"except*" clause.
"break", "continue" and "return" cannot appear in an "except*" clause.
"else" clause
@ -1924,11 +1957,11 @@ class attributes; they are shared by instances. Instance attributes
----------------
If "finally" is present, it specifies a cleanup handler. The "try"
clause is executed, including any "except" and "else" clauses. If an
clause is executed, including any "except" and "else" clauses. If an
exception occurs in any of the clauses and is not handled, the
exception is temporarily saved. The "finally" clause is executed. If
there is a saved exception it is re-raised at the end of the "finally"
clause. If the "finally" clause raises another exception, the saved
clause. If the "finally" clause raises another exception, the saved
exception is set as the context of the new exception. If the "finally"
clause executes a "return", "break" or "continue" statement, the saved
exception is discarded:
@ -4446,8 +4479,8 @@ def inner(x):
Deletion of a name removes the binding of that name from the local or
global namespace, depending on whether the name occurs in a "global"
statement in the same code block. If the name is unbound, a
"NameError" exception will be raised.
statement in the same code block. Trying to delete an unbound name
raises a "NameError" exception.
Deletion of attribute references, subscriptions and slicings is passed
to the primary object involved; deletion of a slicing is in general
@ -5745,9 +5778,15 @@ def whats_on_the_telly(penguin=None):
without "global", although free variables may refer to globals without
being declared global.
The "global" statement applies to the entire scope of a function or
class body. A "SyntaxError" is raised if a variable is used or
assigned to prior to its global declaration in the scope.
The "global" statement applies to the entire current scope (module,
function body or class definition). A "SyntaxError" is raised if a
variable is used or assigned to prior to its global declaration in the
scope.
At the module level, all variables are global, so a "global" statement
has no effect. However, variables must still not be used or assigned
to prior to their "global" declaration. This requirement is relaxed in
the interactive prompt (*REPL*).
**Programmers note:** "global" is a directive to the parser. It
applies only to code parsed at the same time as the "global"
@ -7778,6 +7817,9 @@ class instances.
Customizing module attribute access
-----------------------------------
module.__getattr__()
module.__dir__()
Special names "__getattr__" and "__dir__" can be also used to
customize access to module attributes. The "__getattr__" function at
the module level should accept one argument which is the name of an
@ -7793,6 +7835,8 @@ class instances.
present, this function overrides the standard "dir()" search on a
module.
module.__class__
For a more fine grained customization of the module behavior (setting
attributes, properties, etc.), one can set the "__class__" attribute
of a module object to a subclass of "types.ModuleType". For example:
@ -9007,7 +9051,7 @@ class is used in a class pattern with positional arguments, each
Added in version 3.3.
str.center(width[, fillchar])
str.center(width, fillchar=' ', /)
Return centered in a string of length *width*. Padding is done
using the specified *fillchar* (default is an ASCII space). The
@ -9118,7 +9162,14 @@ class is used in a class pattern with positional arguments, each
Return the lowest index in the string where substring *sub* is
found within the slice "s[start:end]". Optional arguments *start*
and *end* are interpreted as in slice notation. Return "-1" if
*sub* is not found.
*sub* is not found. For example:
>>> 'spam, spam, spam'.find('sp')
0
>>> 'spam, spam, spam'.find('sp', 5)
6
See also "rfind()" and "index()".
Note:
@ -9304,14 +9355,14 @@ class is used in a class pattern with positional arguments, each
>>> ' '.isupper()
False
str.join(iterable)
str.join(iterable, /)
Return a string which is the concatenation of the strings in
*iterable*. A "TypeError" will be raised if there are any non-
string values in *iterable*, including "bytes" objects. The
separator between elements is the string providing this method.
str.ljust(width[, fillchar])
str.ljust(width, fillchar=' ', /)
Return the string left justified in a string of length *width*.
Padding is done using the specified *fillchar* (default is an ASCII
@ -9326,7 +9377,7 @@ class is used in a class pattern with positional arguments, each
The lowercasing algorithm used is described in section 3.13
Default Case Folding of the Unicode Standard.
str.lstrip([chars])
str.lstrip(chars=None, /)
Return a copy of the string with leading characters removed. The
*chars* argument is a string specifying the set of characters to be
@ -9347,7 +9398,8 @@ class is used in a class pattern with positional arguments, each
>>> 'Arthur: three!'.removeprefix('Arthur: ')
'three!'
static str.maketrans(x[, y[, z]])
static str.maketrans(dict, /)
static str.maketrans(from, to, remove='', /)
This static method returns a translation table usable for
"str.translate()".
@ -9358,12 +9410,12 @@ class is used in a class pattern with positional arguments, each
Character keys will then be converted to ordinals.
If there are two arguments, they must be strings of equal length,
and in the resulting dictionary, each character in x will be mapped
to the character at the same position in y. If there is a third
argument, it must be a string, whose characters will be mapped to
"None" in the result.
and in the resulting dictionary, each character in *from* will be
mapped to the character at the same position in *to*. If there is
a third argument, it must be a string, whose characters will be
mapped to "None" in the result.
str.partition(sep)
str.partition(sep, /)
Split the string at the first occurrence of *sep*, and return a
3-tuple containing the part before the separator, the separator
@ -9397,7 +9449,7 @@ class is used in a class pattern with positional arguments, each
Added in version 3.9.
str.replace(old, new, count=-1)
str.replace(old, new, /, count=-1)
Return a copy of the string with all occurrences of substring *old*
replaced by *new*. If *count* is given, only the first *count*
@ -9419,14 +9471,14 @@ class is used in a class pattern with positional arguments, each
Like "rfind()" but raises "ValueError" when the substring *sub* is
not found.
str.rjust(width[, fillchar])
str.rjust(width, fillchar=' ', /)
Return the string right justified in a string of length *width*.
Padding is done using the specified *fillchar* (default is an ASCII
space). The original string is returned if *width* is less than or
equal to "len(s)".
str.rpartition(sep)
str.rpartition(sep, /)
Split the string at the last occurrence of *sep*, and return a
3-tuple containing the part before the separator, the separator
@ -9443,7 +9495,7 @@ class is used in a class pattern with positional arguments, each
from the right, "rsplit()" behaves like "split()" which is
described in detail below.
str.rstrip([chars])
str.rstrip(chars=None, /)
Return a copy of the string with trailing characters removed. The
*chars* argument is a string specifying the set of characters to be
@ -9586,7 +9638,7 @@ class is used in a class pattern with positional arguments, each
With optional *start*, test string beginning at that position.
With optional *end*, stop comparing string at that position.
str.strip([chars])
str.strip(chars=None, /)
Return a copy of the string with the leading and trailing
characters removed. The *chars* argument is a string specifying the
@ -9650,7 +9702,7 @@ class is used in a class pattern with positional arguments, each
>>> titlecase("they're bill's friends.")
"They're Bill's Friends."
str.translate(table)
str.translate(table, /)
Return a copy of the string in which each character has been mapped
through the given translation table. The table must be an object
@ -9678,7 +9730,7 @@ class is used in a class pattern with positional arguments, each
The uppercasing algorithm used is described in section 3.13
Default Case Folding of the Unicode Standard.
str.zfill(width)
str.zfill(width, /)
Return a copy of the string left filled with ASCII "'0'" digits to
make a string of length *width*. A leading sign prefix
@ -10062,15 +10114,29 @@ class is used in a class pattern with positional arguments, each
"except*" clause
================
The "except*" clause(s) are used for handling "ExceptionGroup"s. The
exception type for matching is interpreted as in the case of "except",
but in the case of exception groups we can have partial matches when
the type matches some of the exceptions in the group. This means that
multiple "except*" clauses can execute, each handling part of the
exception group. Each clause executes at most once and handles an
exception group of all matching exceptions. Each exception in the
group is handled by at most one "except*" clause, the first that
matches it.
The "except*" clause(s) specify one or more handlers for groups of
exceptions ("BaseExceptionGroup" instances). A "try" statement can
have either "except" or "except*" clauses, but not both. The exception
type for matching is mandatory in the case of "except*", so "except*:"
is a syntax error. The type is interpreted as in the case of "except",
but matching is performed on the exceptions contained in the group
that is being handled. An "TypeError" is raised if a matching type is
a subclass of "BaseExceptionGroup", because that would have ambiguous
semantics.
When an exception group is raised in the try block, each "except*"
clause splits (see "split()") it into the subgroups of matching and
non-matching exceptions. If the matching subgroup is not empty, it
becomes the handled exception (the value returned from
"sys.exception()") and assigned to the target of the "except*" clause
(if there is one). Then, the body of the "except*" clause executes. If
the non-matching subgroup is not empty, it is processed by the next
"except*" in the same manner. This continues until all exceptions in
the group have been matched, or the last "except*" clause has run.
After all "except*" clauses execute, the group of unhandled exceptions
is merged with any exceptions that were raised or re-raised from
within "except*" clauses. This merged exception group propagates on.:
>>> try:
... raise ExceptionGroup("eg",
@ -10083,20 +10149,19 @@ class is used in a class pattern with positional arguments, each
caught <class 'ExceptionGroup'> with nested (TypeError(2),)
caught <class 'ExceptionGroup'> with nested (OSError(3), OSError(4))
+ Exception Group Traceback (most recent call last):
| File "<stdin>", line 2, in <module>
| ExceptionGroup: eg
| File "<doctest default[0]>", line 2, in <module>
| raise ExceptionGroup("eg",
| [ValueError(1), TypeError(2), OSError(3), OSError(4)])
| ExceptionGroup: eg (1 sub-exception)
+-+---------------- 1 ----------------
| ValueError: 1
+------------------------------------
Any remaining exceptions that were not handled by any "except*" clause
are re-raised at the end, along with all exceptions that were raised
from within the "except*" clauses. If this list contains more than one
exception to reraise, they are combined into an exception group.
If the raised exception is not an exception group and its type matches
one of the "except*" clauses, it is caught and wrapped by an exception
group with an empty message string.
If the exception raised from the "try" block is not an exception group
and its type matches one of the "except*" clauses, it is caught and
wrapped by an exception group with an empty message string. This
ensures that the type of the target "e" is consistently
"BaseExceptionGroup":
>>> try:
... raise BlockingIOError
@ -10105,13 +10170,7 @@ class is used in a class pattern with positional arguments, each
...
ExceptionGroup('', (BlockingIOError()))
An "except*" clause must have a matching expression; it cannot be
"except*:". Furthermore, this expression cannot contain exception
group types, because that would have ambiguous semantics.
It is not possible to mix "except" and "except*" in the same "try".
The "break", "continue", and "return" statements cannot appear in an
"except*" clause.
"break", "continue" and "return" cannot appear in an "except*" clause.
"else" clause
@ -10127,11 +10186,11 @@ class is used in a class pattern with positional arguments, each
================
If "finally" is present, it specifies a cleanup handler. The "try"
clause is executed, including any "except" and "else" clauses. If an
clause is executed, including any "except" and "else" clauses. If an
exception occurs in any of the clauses and is not handled, the
exception is temporarily saved. The "finally" clause is executed. If
there is a saved exception it is re-raised at the end of the "finally"
clause. If the "finally" clause raises another exception, the saved
clause. If the "finally" clause raises another exception, the saved
exception is set as the context of the new exception. If the "finally"
clause executes a "return", "break" or "continue" statement, the saved
exception is discarded:
@ -11515,8 +11574,8 @@ class instance has a namespace implemented as a dictionary which is
dictionary entry.
class dict(**kwargs)
class dict(mapping, **kwargs)
class dict(iterable, **kwargs)
class dict(mapping, /, **kwargs)
class dict(iterable, /, **kwargs)
Return a new dictionary initialized from an optional positional
argument and a possibly empty set of keyword arguments.
@ -11692,7 +11751,8 @@ class dict(iterable, **kwargs)
Return a new view of the dictionarys keys. See the
documentation of view objects.
pop(key[, default])
pop(key, /)
pop(key, default, /)
If *key* is in the dictionary, remove it and return its value,
else return *default*. If *default* is not given and *key* is
@ -11723,10 +11783,13 @@ class dict(iterable, **kwargs)
*key* with a value of *default* and return *default*. *default*
defaults to "None".
update([other])
update(**kwargs)
update(mapping, /, **kwargs)
update(iterable, /, **kwargs)
Update the dictionary with the key/value pairs from *other*,
overwriting existing keys. Return "None".
Update the dictionary with the key/value pairs from *mapping* or
*iterable* and *kwargs*, overwriting existing keys. Return
"None".
"update()" accepts either another object with a "keys()" method
(in which case "__getitem__()" is called with every key returned
@ -11991,7 +12054,7 @@ class dict(iterable, **kwargs)
| "s * n" or "n * s" | equivalent to adding *s* to | (2)(7) |
| | itself *n* times | |
+----------------------------+----------------------------------+------------+
| "s[i]" | *i*th item of *s*, origin 0 | (3)(9) |
| "s[i]" | *i*th item of *s*, origin 0 | (3)(8) |
+----------------------------+----------------------------------+------------+
| "s[i:j]" | slice of *s* from *i* to *j* | (3)(4) |
+----------------------------+----------------------------------+------------+
@ -12004,13 +12067,6 @@ class dict(iterable, **kwargs)
+----------------------------+----------------------------------+------------+
| "max(s)" | largest item of *s* | |
+----------------------------+----------------------------------+------------+
| "s.index(x[, i[, j]])" | index of the first occurrence of | (8) |
| | *x* in *s* (at or after index | |
| | *i* and before index *j*) | |
+----------------------------+----------------------------------+------------+
| "s.count(x)" | total number of occurrences of | |
| | *x* in *s* | |
+----------------------------+----------------------------------+------------+
Sequences of the same type also support comparisons. In particular,
tuples and lists are compared lexicographically by comparing
@ -12107,15 +12163,31 @@ class dict(iterable, **kwargs)
that follow specific patterns, and hence dont support sequence
concatenation or repetition.
8. "index" raises "ValueError" when *x* is not found in *s*. Not all
implementations support passing the additional arguments *i* and
*j*. These arguments allow efficient searching of subsections of
the sequence. Passing the extra arguments is roughly equivalent to
using "s[i:j].index(x)", only without copying any data and with the
returned index being relative to the start of the sequence rather
than the start of the slice.
8. An "IndexError" is raised if *i* is outside the sequence range.
9. An "IndexError" is raised if *i* is outside the sequence range.
-[ Sequence Methods ]-
Sequence types also support the following methods:
sequence.count(value, /)
Return the total number of occurrences of *value* in *sequence*.
sequence.index(value[, start[, stop])
Return the index of the first occurrence of *value* in *sequence*.
Raises "ValueError" if *value* is not found in *sequence*.
The *start* or *stop* arguments allow for efficient searching of
subsections of the sequence, beginning at *start* and ending at
*stop*. This is roughly equivalent to "start +
sequence[start:stop].index(value)", only without copying any data.
Caution:
Not all sequence types support passing the *start* and *stop*
arguments.
Immutable Sequence Types
@ -12167,64 +12239,80 @@ class dict(iterable, **kwargs)
| "del s[i:j:k]" | removes the elements of | |
| | "s[i:j:k]" from the list | |
+--------------------------------+----------------------------------+-----------------------+
| "s.append(x)" | appends *x* to the end of the | |
| | sequence (same as | |
| | "s[len(s):len(s)] = [x]") | |
+--------------------------------+----------------------------------+-----------------------+
| "s.clear()" | removes all items from *s* (same | (5) |
| | as "del s[:]") | |
+--------------------------------+----------------------------------+-----------------------+
| "s.copy()" | creates a shallow copy of *s* | (5) |
| | (same as "s[:]") | |
+--------------------------------+----------------------------------+-----------------------+
| "s.extend(t)" or "s += t" | extends *s* with the contents of | |
| "s += t" | extends *s* with the contents of | |
| | *t* (for the most part the same | |
| | as "s[len(s):len(s)] = t") | |
+--------------------------------+----------------------------------+-----------------------+
| "s *= n" | updates *s* with its contents | (6) |
| "s *= n" | updates *s* with its contents | (2) |
| | repeated *n* times | |
+--------------------------------+----------------------------------+-----------------------+
| "s.insert(i, x)" | inserts *x* into *s* at the | |
| | index given by *i* (same as | |
| | "s[i:i] = [x]") | |
+--------------------------------+----------------------------------+-----------------------+
| "s.pop()" or "s.pop(i)" | retrieves the item at *i* and | (2) |
| | also removes it from *s* | |
+--------------------------------+----------------------------------+-----------------------+
| "s.remove(x)" | removes the first item from *s* | (3) |
| | where "s[i]" is equal to *x* | |
+--------------------------------+----------------------------------+-----------------------+
| "s.reverse()" | reverses the items of *s* in | (4) |
| | place | |
+--------------------------------+----------------------------------+-----------------------+
Notes:
1. If *k* is not equal to "1", *t* must have the same length as the
slice it is replacing.
2. The optional argument *i* defaults to "-1", so that by default the
last item is removed and returned.
3. "remove()" raises "ValueError" when *x* is not found in *s*.
4. The "reverse()" method modifies the sequence in place for economy
of space when reversing a large sequence. To remind users that it
operates by side effect, it does not return the reversed sequence.
5. "clear()" and "copy()" are included for consistency with the
interfaces of mutable containers that dont support slicing
operations (such as "dict" and "set"). "copy()" is not part of the
"collections.abc.MutableSequence" ABC, but most concrete mutable
sequence classes provide it.
Added in version 3.3: "clear()" and "copy()" methods.
6. The value *n* is an integer, or an object implementing
2. The value *n* is an integer, or an object implementing
"__index__()". Zero and negative values of *n* clear the sequence.
Items in the sequence are not copied; they are referenced multiple
times, as explained for "s * n" under Common Sequence Operations.
-[ Mutable Sequence Methods ]-
Mutable sequence types also support the following methods:
sequence.append(value, /)
Append *value* to the end of the sequence This is equivalent to
writing "seq[len(seq):len(seq)] = [value]".
sequence.clear()
Added in version 3.3.
Remove all items from *sequence*. This is equivalent to writing
"del sequence[:]".
sequence.copy()
Added in version 3.3.
Create a shallow copy of *sequence*. This is equivalent to writing
"sequence[:]".
Hint:
The "copy()" method is not part of the "MutableSequence" "ABC",
but most concrete mutable sequence types provide it.
sequence.extend(iterable, /)
Extend *sequence* with the contents of *iterable*. For the most
part, this is the same as writing "seq[len(seq):len(seq)] =
iterable".
sequence.insert(index, value, /)
Insert *value* into *sequence* at the given *index*. This is
equivalent to writing "sequence[index:index] = [value]".
sequence.pop(index=-1, /)
Retrieve the item at *index* and also removes it from *sequence*.
By default, the last item in *sequence* is removed and returned.
sequence.remove(value, /)
Remove the first item from *sequence* where "sequence[i] == value".
Raises "ValueError" if *value* is not found in *sequence*.
sequence.reverse()
Reverse the items of *sequence* in place. This method maintains
economy of space when reversing a large sequence. To remind users
that it operates by side-effect, it returns "None".
Lists
=====
@ -12233,7 +12321,7 @@ class dict(iterable, **kwargs)
homogeneous items (where the precise degree of similarity will vary by
application).
class list([iterable])
class list(iterable=(), /)
Lists may be constructed in several ways:
@ -12314,7 +12402,7 @@ class list([iterable])
of homogeneous data is needed (such as allowing storage in a "set" or
"dict" instance).
class tuple([iterable])
class tuple(iterable=(), /)
Tuples may be constructed in a number of ways:
@ -12354,8 +12442,8 @@ class tuple([iterable])
The "range" type represents an immutable sequence of numbers and is
commonly used for looping a specific number of times in "for" loops.
class range(stop)
class range(start, stop[, step])
class range(stop, /)
class range(start, stop, step=1, /)
The arguments to the range constructor must be integers (either
built-in "int" or any object that implements the "__index__()"
@ -12499,63 +12587,79 @@ class range(start, stop[, step])
| "del s[i:j:k]" | removes the elements of | |
| | "s[i:j:k]" from the list | |
+--------------------------------+----------------------------------+-----------------------+
| "s.append(x)" | appends *x* to the end of the | |
| | sequence (same as | |
| | "s[len(s):len(s)] = [x]") | |
+--------------------------------+----------------------------------+-----------------------+
| "s.clear()" | removes all items from *s* (same | (5) |
| | as "del s[:]") | |
+--------------------------------+----------------------------------+-----------------------+
| "s.copy()" | creates a shallow copy of *s* | (5) |
| | (same as "s[:]") | |
+--------------------------------+----------------------------------+-----------------------+
| "s.extend(t)" or "s += t" | extends *s* with the contents of | |
| "s += t" | extends *s* with the contents of | |
| | *t* (for the most part the same | |
| | as "s[len(s):len(s)] = t") | |
+--------------------------------+----------------------------------+-----------------------+
| "s *= n" | updates *s* with its contents | (6) |
| "s *= n" | updates *s* with its contents | (2) |
| | repeated *n* times | |
+--------------------------------+----------------------------------+-----------------------+
| "s.insert(i, x)" | inserts *x* into *s* at the | |
| | index given by *i* (same as | |
| | "s[i:i] = [x]") | |
+--------------------------------+----------------------------------+-----------------------+
| "s.pop()" or "s.pop(i)" | retrieves the item at *i* and | (2) |
| | also removes it from *s* | |
+--------------------------------+----------------------------------+-----------------------+
| "s.remove(x)" | removes the first item from *s* | (3) |
| | where "s[i]" is equal to *x* | |
+--------------------------------+----------------------------------+-----------------------+
| "s.reverse()" | reverses the items of *s* in | (4) |
| | place | |
+--------------------------------+----------------------------------+-----------------------+
Notes:
1. If *k* is not equal to "1", *t* must have the same length as the
slice it is replacing.
2. The optional argument *i* defaults to "-1", so that by default the
last item is removed and returned.
3. "remove()" raises "ValueError" when *x* is not found in *s*.
4. The "reverse()" method modifies the sequence in place for economy
of space when reversing a large sequence. To remind users that it
operates by side effect, it does not return the reversed sequence.
5. "clear()" and "copy()" are included for consistency with the
interfaces of mutable containers that dont support slicing
operations (such as "dict" and "set"). "copy()" is not part of the
"collections.abc.MutableSequence" ABC, but most concrete mutable
sequence classes provide it.
Added in version 3.3: "clear()" and "copy()" methods.
6. The value *n* is an integer, or an object implementing
2. The value *n* is an integer, or an object implementing
"__index__()". Zero and negative values of *n* clear the sequence.
Items in the sequence are not copied; they are referenced multiple
times, as explained for "s * n" under Common Sequence Operations.
-[ Mutable Sequence Methods ]-
Mutable sequence types also support the following methods:
sequence.append(value, /)
Append *value* to the end of the sequence This is equivalent to
writing "seq[len(seq):len(seq)] = [value]".
sequence.clear()
Added in version 3.3.
Remove all items from *sequence*. This is equivalent to writing
"del sequence[:]".
sequence.copy()
Added in version 3.3.
Create a shallow copy of *sequence*. This is equivalent to writing
"sequence[:]".
Hint:
The "copy()" method is not part of the "MutableSequence" "ABC",
but most concrete mutable sequence types provide it.
sequence.extend(iterable, /)
Extend *sequence* with the contents of *iterable*. For the most
part, this is the same as writing "seq[len(seq):len(seq)] =
iterable".
sequence.insert(index, value, /)
Insert *value* into *sequence* at the given *index*. This is
equivalent to writing "sequence[index:index] = [value]".
sequence.pop(index=-1, /)
Retrieve the item at *index* and also removes it from *sequence*.
By default, the last item in *sequence* is removed and returned.
sequence.remove(value, /)
Remove the first item from *sequence* where "sequence[i] == value".
Raises "ValueError" if *value* is not found in *sequence*.
sequence.reverse()
Reverse the items of *sequence* in place. This method maintains
economy of space when reversing a large sequence. To remind users
that it operates by side-effect, it returns "None".
''',
'unary': r'''Unary arithmetic and bitwise operations
***************************************