Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3795d12

Browse files
committed
Issue #16701: Document += and *= for mutable sequences
1 parent cb29e8c commit 3795d12

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,10 +1063,14 @@ accepts integers that meet the value restriction ``0 <= x <= 255``).
10631063
| ``s.copy()`` | creates a shallow copy of ``s``| \(5) |
10641064
| | (same as ``s[:]``) | |
10651065
+------------------------------+--------------------------------+---------------------+
1066-
| ``s.extend(t)`` | extends *s* with the | |
1067-
| | contents of *t* (same as | |
1066+
| ``s.extend(t)`` or | extends *s* with the | |
1067+
| ``s += t`` | contents of *t* (for the | |
1068+
| | most part the same as | |
10681069
| | ``s[len(s):len(s)] = t``) | |
10691070
+------------------------------+--------------------------------+---------------------+
1071+
| ``s *= n`` | updates *s* with its contents | \(6) |
1072+
| | repeated *n* times | |
1073+
+------------------------------+--------------------------------+---------------------+
10701074
| ``s.insert(i, x)`` | inserts *x* into *s* at the | |
10711075
| | index given by *i* | |
10721076
| | (same as ``s[i:i] = [x]``) | |
@@ -1107,6 +1111,12 @@ Notes:
11071111
.. versionadded:: 3.3
11081112
:meth:`clear` and :meth:`!copy` methods.
11091113

1114+
(6)
1115+
The value *n* is an integer, or an object implementing
1116+
:meth:`~object.__index__`. Zero and negative values of *n* clear
1117+
the sequence. Items in the sequence are not copied; they are referenced
1118+
multiple times, as explained for ``s * n`` under :ref:`typesseq-common`.
1119+
11101120

11111121
.. _typesseq-list:
11121122

0 commit comments

Comments
 (0)