]> granicus.if.org Git - python/commitdiff
Introduce copy by slicing, used in later chapters.
authorGeorg Brandl <georg@python.org>
Sun, 21 Mar 2010 09:17:41 +0000 (09:17 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 21 Mar 2010 09:17:41 +0000 (09:17 +0000)
Doc/tutorial/introduction.rst

index 1d67ed3df022cc93918edef56a6efee920f4de17..c953394e5d17d9d7fc72db062e1960d49ba06d45 100644 (file)
@@ -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::