From: Georg Brandl Date: Sun, 21 Mar 2010 09:17:41 +0000 (+0000) Subject: Introduce copy by slicing, used in later chapters. X-Git-Tag: v2.7b1~293 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0fcd8821014f023936f0c331258a1ea6eed7bcf2;p=python Introduce copy by slicing, used in later chapters. --- diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 1d67ed3df0..c953394e5d 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::