summaryrefslogtreecommitdiffstats
path: root/Doc/tutorial
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-03-21 09:17:41 (GMT)
committerGeorg Brandl <georg@python.org>2010-03-21 09:17:41 (GMT)
commit0fcd8821014f023936f0c331258a1ea6eed7bcf2 (patch)
tree4dd1eba8dc3403ef8ae2b6f9762eb208c07041cf /Doc/tutorial
parentd1068be653c35bb0b6446d2fa85a39a36a7994b6 (diff)
downloadcpython-0fcd8821014f023936f0c331258a1ea6eed7bcf2.zip
cpython-0fcd8821014f023936f0c331258a1ea6eed7bcf2.tar.gz
cpython-0fcd8821014f023936f0c331258a1ea6eed7bcf2.tar.bz2
Introduce copy by slicing, used in later chapters.
Diffstat (limited to 'Doc/tutorial')
-rw-r--r--Doc/tutorial/introduction.rst6
1 files changed, 6 insertions, 0 deletions
diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst
index 1d67ed3..c953394 100644
--- a/Doc/tutorial/introduction.rst
+++ b/Doc/tutorial/introduction.rst
@@ -523,6 +523,12 @@ concatenated and so on::
>>> 3*a[:3] + ['Boo!']
['spam', 'eggs', 100, 'spam', 'eggs', 100, 'spam', 'eggs', 100, 'Boo!']
+All slice operations return a new list containing the requested elements. This
+means that the following slice returns a shallow copy of the list *a*::
+
+ >>> a[:]
+ ['spam', 'eggs', 100, 1234]
+
Unlike strings, which are *immutable*, it is possible to change individual
elements of a list::