mirror of https://github.com/python/cpython.git
[3.13] gh-101100: Fix Sphinx warnings about list methods (GH-127054) (#127511)
Co-authored-by: Yuki Kobayashi <drsuaimqjgar@gmail.com>
This commit is contained in:
parent
4bafce0912
commit
26f1e88aae
|
@ -783,10 +783,10 @@ sequence of key-value pairs into a dictionary of lists:
|
||||||
|
|
||||||
When each key is encountered for the first time, it is not already in the
|
When each key is encountered for the first time, it is not already in the
|
||||||
mapping; so an entry is automatically created using the :attr:`~defaultdict.default_factory`
|
mapping; so an entry is automatically created using the :attr:`~defaultdict.default_factory`
|
||||||
function which returns an empty :class:`list`. The :meth:`list.append`
|
function which returns an empty :class:`list`. The :meth:`!list.append`
|
||||||
operation then attaches the value to the new list. When keys are encountered
|
operation then attaches the value to the new list. When keys are encountered
|
||||||
again, the look-up proceeds normally (returning the list for that key) and the
|
again, the look-up proceeds normally (returning the list for that key) and the
|
||||||
:meth:`list.append` operation adds another value to the list. This technique is
|
:meth:`!list.append` operation adds another value to the list. This technique is
|
||||||
simpler and faster than an equivalent technique using :meth:`dict.setdefault`:
|
simpler and faster than an equivalent technique using :meth:`dict.setdefault`:
|
||||||
|
|
||||||
>>> d = {}
|
>>> d = {}
|
||||||
|
|
|
@ -72,7 +72,6 @@ Doc/library/xmlrpc.server.rst
|
||||||
Doc/library/zlib.rst
|
Doc/library/zlib.rst
|
||||||
Doc/reference/compound_stmts.rst
|
Doc/reference/compound_stmts.rst
|
||||||
Doc/reference/datamodel.rst
|
Doc/reference/datamodel.rst
|
||||||
Doc/tutorial/datastructures.rst
|
|
||||||
Doc/using/windows.rst
|
Doc/using/windows.rst
|
||||||
Doc/whatsnew/2.4.rst
|
Doc/whatsnew/2.4.rst
|
||||||
Doc/whatsnew/2.5.rst
|
Doc/whatsnew/2.5.rst
|
||||||
|
|
|
@ -142,8 +142,8 @@ Using Lists as Stacks
|
||||||
|
|
||||||
The list methods make it very easy to use a list as a stack, where the last
|
The list methods make it very easy to use a list as a stack, where the last
|
||||||
element added is the first element retrieved ("last-in, first-out"). To add an
|
element added is the first element retrieved ("last-in, first-out"). To add an
|
||||||
item to the top of the stack, use :meth:`~list.append`. To retrieve an item from the
|
item to the top of the stack, use :meth:`!~list.append`. To retrieve an item from the
|
||||||
top of the stack, use :meth:`~list.pop` without an explicit index. For example::
|
top of the stack, use :meth:`!~list.pop` without an explicit index. For example::
|
||||||
|
|
||||||
>>> stack = [3, 4, 5]
|
>>> stack = [3, 4, 5]
|
||||||
>>> stack.append(6)
|
>>> stack.append(6)
|
||||||
|
@ -340,7 +340,7 @@ The :keyword:`!del` statement
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
There is a way to remove an item from a list given its index instead of its
|
There is a way to remove an item from a list given its index instead of its
|
||||||
value: the :keyword:`del` statement. This differs from the :meth:`~list.pop` method
|
value: the :keyword:`del` statement. This differs from the :meth:`!~list.pop` method
|
||||||
which returns a value. The :keyword:`!del` statement can also be used to remove
|
which returns a value. The :keyword:`!del` statement can also be used to remove
|
||||||
slices from a list or clear the entire list (which we did earlier by assignment
|
slices from a list or clear the entire list (which we did earlier by assignment
|
||||||
of an empty list to the slice). For example::
|
of an empty list to the slice). For example::
|
||||||
|
@ -500,8 +500,8 @@ any immutable type; strings and numbers can always be keys. Tuples can be used
|
||||||
as keys if they contain only strings, numbers, or tuples; if a tuple contains
|
as keys if they contain only strings, numbers, or tuples; if a tuple contains
|
||||||
any mutable object either directly or indirectly, it cannot be used as a key.
|
any mutable object either directly or indirectly, it cannot be used as a key.
|
||||||
You can't use lists as keys, since lists can be modified in place using index
|
You can't use lists as keys, since lists can be modified in place using index
|
||||||
assignments, slice assignments, or methods like :meth:`~list.append` and
|
assignments, slice assignments, or methods like :meth:`!~list.append` and
|
||||||
:meth:`~list.extend`.
|
:meth:`!~list.extend`.
|
||||||
|
|
||||||
It is best to think of a dictionary as a set of *key: value* pairs,
|
It is best to think of a dictionary as a set of *key: value* pairs,
|
||||||
with the requirement that the keys are unique (within one dictionary). A pair of
|
with the requirement that the keys are unique (within one dictionary). A pair of
|
||||||
|
|
Loading…
Reference in New Issue