Dear all, This has been driving me mad. According to the python documentation, you can modify a copy of a list without modifying the original using the following code:
sage: L = [] sage: M = L[:] # create a copy sage: # modify L only sage: L.append(1) sage: M [] Now, I want to do the same with a nested list, but I do not manage to unlink the two. See the example below, where I also tried copy(L) to no avail. I hope that someone can help. Thanks already! THIS WORKS: sage: L = [1,2,3] sage: M = L[:] # create a copy sage: # modify L only sage: L[0]='rubbish' sage: M [1, 2, 3] THIS DOES NOT: sage: L = [[1,2,3],[4,5,6]] sage: M = L[:] # create a copy sage: # modify L only sage: L[0][0]='rubbish' sage: M [['rubbish', 2, 3], [4, 5, 6]] NOR DOES THIS: sage: L = [[1,2,3],[4,5,6]] sage: M = copy(L) # create a copy sage: # modify L only sage: L[0][0]='rubbish' sage: M [['rubbish', 2, 3], [4, 5, 6]] -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org