A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2010-June/101040.html below:

[Python-Dev] docs - Copy

[Python-Dev] docs - CopyRich Healey healey.rich at gmail.com
Fri Jun 25 02:51:18 CEST 2010
http://docs.python.org/library/copy.html

Just near the bottom it reads:

"""Shallow copies of dictionaries can be made using dict.copy(), and
of lists by assigning a slice of the entire list, for example,
copied_list = original_list[:]."""


Surely this is a typo? To my understanding, copied_list =
original_list[:] gives you a clean copy (slicing returns a new
object....)

Can this be updated? Or someone explain to me why it's correct?

Cheers

Example:


>>> t = [1, 2, 3]
>>> y = t
>>> u = t[:]
>>> y[1] = "rawr"
>>> t
[1, 'rawr', 3]
>>> u
[1, 2, 3]
>>>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4