summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMartin Panter <vadmium>2015-09-07 02:10:59 (GMT)
committerMartin Panter <vadmium>2015-09-07 02:10:59 (GMT)
commit06dc2fa3f6fe89d55538031b7b0fa7d988983e0e (patch)
tree1d3f9cfe4d6508b14391da05a573c1c74bce29ee /Doc
parent20a2c6482e28a2ca8d257ba646f2b8ead4837387 (diff)
parent7f02d6d0d946a724ea1f4f1ffb6680c881dbad33 (diff)
downloadcpython-06dc2fa3f6fe89d55538031b7b0fa7d988983e0e.zip
cpython-06dc2fa3f6fe89d55538031b7b0fa7d988983e0e.tar.gz
cpython-06dc2fa3f6fe89d55538031b7b0fa7d988983e0e.tar.bz2
Issue #23406: Merge 3.4 into 3.5
Diffstat (limited to 'Doc')
-rw-r--r--Doc/faq/programming.rst2
-rw-r--r--Doc/library/stdtypes.rst15
2 files changed, 11 insertions, 6 deletions
diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
index 2d3cb1c..67a9c56 100644
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -1164,6 +1164,8 @@ analogue of lisp car is ``lisp_list[0]`` and the analogue of cdr is
usually a lot slower than using Python lists.
+.. _faq-multidimensional-list:
+
How do I create a multidimensional list?
----------------------------------------
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 8573416..b3c9e23 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -854,8 +854,8 @@ operations have the same priority as the corresponding numeric operations.
| ``s + t`` | the concatenation of *s* and | (6)(7) |
| | *t* | |
+--------------------------+--------------------------------+----------+
-| ``s * n`` or | *n* shallow copies of *s* | (2)(7) |
-| ``n * s`` | concatenated | |
+| ``s * n`` or | equivalent to adding *s* to | (2)(7) |
+| ``n * s`` | itself *n* times | |
+--------------------------+--------------------------------+----------+
| ``s[i]`` | *i*\ th item of *s*, origin 0 | \(3) |
+--------------------------+--------------------------------+----------+
@@ -897,9 +897,9 @@ Notes:
(2)
Values of *n* less than ``0`` are treated as ``0`` (which yields an empty
- sequence of the same type as *s*). Note also that the copies are shallow;
- nested structures are not copied. This often haunts new Python programmers;
- consider::
+ sequence of the same type as *s*). Note that items in the sequence *s*
+ are not copied; they are referenced multiple times. This often haunts
+ new Python programmers; consider::
>>> lists = [[]] * 3
>>> lists
@@ -909,7 +909,7 @@ Notes:
[[3], [3], [3]]
What has happened is that ``[[]]`` is a one-element list containing an empty
- list, so all three elements of ``[[]] * 3`` are (pointers to) this single empty
+ list, so all three elements of ``[[]] * 3`` are references to this single empty
list. Modifying any of the elements of ``lists`` modifies this single list.
You can create a list of different lists this way::
@@ -920,6 +920,9 @@ Notes:
>>> lists
[[3], [5], [7]]
+ Further explanation is available in the FAQ entry
+ :ref:`faq-multidimensional-list`.
+
(3)
If *i* or *j* is negative, the index is relative to the end of the string:
``len(s) + i`` or ``len(s) + j`` is substituted. But note that ``-0`` is