]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #16701: Document += and *= for mutable sequences
authorMartin Panter <vadmium+py@gmail.com>
Sat, 3 Oct 2015 07:46:04 +0000 (07:46 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Sat, 3 Oct 2015 07:46:04 +0000 (07:46 +0000)
Doc/library/stdtypes.rst

index c3dc63de9fd3070035263eb9c2a12b27bac10bd8..ce3c5320d8b725c2686750f652db63081dbab97e 100644 (file)
@@ -1063,10 +1063,14 @@ accepts integers that meet the value restriction ``0 <= x <= 255``).
 | ``s.copy()``                 | creates a shallow copy of ``s``| \(5)                |
 |                              | (same as ``s[:]``)             |                     |
 +------------------------------+--------------------------------+---------------------+
-| ``s.extend(t)``              | extends *s* with the           |                     |
-|                              | contents of *t* (same as       |                     |
+| ``s.extend(t)`` or           | extends *s* with the           |                     |
+| ``s += t``                   | contents of *t* (for the       |                     |
+|                              | most part the same as          |                     |
 |                              | ``s[len(s):len(s)] = t``)      |                     |
 +------------------------------+--------------------------------+---------------------+
+| ``s *= n``                   | updates *s* with its contents  | \(6)                |
+|                              | repeated *n* times             |                     |
++------------------------------+--------------------------------+---------------------+
 | ``s.insert(i, x)``           | inserts *x* into *s* at the    |                     |
 |                              | index given by *i*             |                     |
 |                              | (same as ``s[i:i] = [x]``)     |                     |
@@ -1107,6 +1111,12 @@ Notes:
    .. versionadded:: 3.3
       :meth:`clear` and :meth:`!copy` methods.
 
+(6)
+   The value *n* is an integer, or an object implementing
+   :meth:`~object.__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 :ref:`typesseq-common`.
+
 
 .. _typesseq-list: