possible python bug here
manuel
manuelbastioniNOSPAM at tin.it
Sun Aug 29 11:10:44 EDT 2004
In the sample below, the foo function modify the b list,
but I think it should modify only c, not b! It work
correctly if if b is one dimension list instead two.
def foo(aList):
print "use foo..."
aList[2][0] += .35
aList[2][1] += .35
aList[2][2] += .35
p = [2.5,2.5,2.5]
b = [p,p,p,p]
c=b[:] #c is a totally new list cloned from b, it's not an alias!
print "b = ",b[2]
foo(c) #The argument is c, not b! Why b is modified too?
print "b = ", b[2]# after foo(c), the list b now is different!
More information about the Python-list
mailing list