mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
Introduce copy by slicing, used in later chapters.
This commit is contained in:
parent
d1068be653
commit
0fcd882101
1 changed files with 6 additions and 0 deletions
|
@ -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::
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue