<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16825" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>
<P>Dear all,<BR><BR>we have a doubt concerning the list copying and the id
function <BR>applied to a copied element of a list.<BR>- shallow copy: produce a
new object that is not linked to <BR>the native object. Slicing on a list
produces a shallow copy of the original one.<BR>- deep copy: bit-bit copy (in
other words we have here a <BR>reference to the native object
(link))<BR>::::::::::::::::::::CODE:::::::::::::::::::::::::::::::::::::::::::::<BR>#list1<BR>l1=[1,2]<BR>l2=[3,l1]</P>
<P><BR>#shallow copy<BR>l3=l2[:]</P>
<P>#deep copy: (bit-bit) or by reference<BR>l4=l2<BR>print 'id(l2)', id(l2),
'id(l3)', id(l3), 'id(l4)', id(l4)<BR>print 'id(l2[1])', id(l2[1]), 'id(l3[1])',
id(l3[1]), 'id(l4[1])',
id(l4[1])<BR><BR>:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>and
by applying the id() function we get:<BR>id(l2) 13069528 (ok)<BR>id(l3) 10704976
(ok is a shallow copy)<BR>id(l4) 13069528 (ok is a deep copy)<BR>id(l2[1])
13047248 (ok)<BR>id(l3[1]) 13047248 (why is not recursive the <BR>shallow
copy?)<BR>id(l4[1]) 13047248 (ok, is deep )<BR><BR><BR><BR>Therefore, is not
clear to us why in list copy the shallow does not <BR>affect the sub-list
object. In other words the shallow copy is not <BR>'recursive' within a
shollowed copied object.<BR><BR>More in general, we don't understand the
behavior of the id() function. Doesn't return the object identity (object adress
memory)??</P>
<P>Why the object identity of the three variables in the following example is
the same?? Does the id() function behave like the C/C++ adress-operator
&??</P>
<P><BR>::::::::::::::::::::::::::::::::CODE-2:::::::::::::::::::::::::::<BR><BR>a=23<BR>b=23<BR>c=a<BR><BR>print
'id(a):', id(a), 'id(b):', id(b), 'id(c): ',id(c)<BR>id(a): 9985904 (ok)
<BR>id(b): 9985904 (???)<BR>id(c): 9985904
(???)<BR>::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>Thank
you very much<BR><BR><BR><BR></P><FONT face=Arial size=2><FONT face=Arial
size=2></FONT></FONT></FONT></DIV></BODY></HTML>