On Jul 19, 10:21 am, Falcolas <[EMAIL PROTECTED]> 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?
W
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
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 d
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?
--
http://mail.python.org/mailman/listinfo/python-list
Joe Riopel <[EMAIL PROTECTED]> wrote:
> I am pretty new to python but this works:
>
> >>> list_one = [0,1,2,3,4,5,6,7,8,9]
> >>> list_two = [i for i in list_one]
> >>> print list_two
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>> list_two = list_one[:]
or
>> list_two = list(list_one)
are better :D
--
The standard idiom (I guess) is to use the slice
>>> a=[1,2,3,4]
>>> b=a
>>> b is a
True
>>> b
[1, 2, 3, 4]
>>> c=a[:]
>>> c is a
False
>>> c
[1, 2, 3, 4]
This is shallow copy
If you want deep copy then
from copy import deepcopy
--
http://mail.python.org/mailman/listinfo/python-list
I forgot to mention that you can go here for a little more of an explanation:
http://diveintopython.org/native_data_types/mapping_lists.html
--
http://mail.python.org/mailman/listinfo/python-list
On 7/18/07, Robert Rawlins - Think Blue
<[EMAIL PROTECTED]> wrote:
> What's the best way to create a copy of a list?
I am pretty new to python but this works:
>>> list_one = [0,1,2,3,4,5,6,7,8,9]
>>> list_two = [i for i in list_one]
>>> print list_two
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>
--
http:/
On 18/07/07, Robert Rawlins - Think Blue
<[EMAIL PROTECTED]> wrote:
>
> What's the best way to create a copy of a list? I've seen several method and
> I'm not sure what to use. This will be in a class and one method creates a
> list which I then want to move to the self scope, like so:
>
listB =
Hello Guys,
What's the best way to create a copy of a list? I've seen several method and
I'm not sure what to use. This will be in a class and one method creates a
list which I then want to move to the self scope, like so:
__Init__(self):
Self.myList = []
regenerateList
10 matches
Mail list logo