A slice still has some references to the old objects a deep copy is a
totally new object!
On 19 Jul 2007 17:04:00 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]>
wrote:
On Thu, 19 Jul 2007 09:21:54 -0700, Falcolas wrote:
> On Jul 18, 6:56 am, "Rustom Mody" <[EMAIL PROTECTED]> wrote:
>> This is shallow copy
>> If you want deep copy then
>> from copy import deepcopy
>
> What will a "deep copy" of a list give you that using the slice
> notation will not?
Well, a deep copy of course. ;-)
In [6]: import copy
In [7]: a = [[1, 2], [3, 4]]
In [8]: b = a[:]
In [9]: c = copy.deepcopy(a)
In [10]: a[0][1] = 42
In [11]: a
Out[11]: [[1, 42], [3, 4]]
In [12]: b
Out[12]: [[1, 42], [3, 4]]
In [13]: c
Out[13]: [[1, 2], [3, 4]]
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
--
http://www.goldwatches.com/Watches.asp?Brand=14
http://www.jewelerslounge.com
--
http://mail.python.org/mailman/listinfo/python-list