Say I have a vector a
defined as:
a = [[1,2,3],[-1,-2,-3]]
I have learned that to create a copy of the object a
without referencing it I should use the following syntaxis:
b = a[:]
Indeed, if I execute the following statements:
b = []
print a
the output is
>>> [[1,2,3],[-1,-2,-3]]
exactly as I was expecting. Though, if I do the following:
b = a[:]
b[0][2] = 'change a'
print a
the output is
>>> [[1,2,'change a'],[-1,-2,-3]]
So it's clear to me that the object a[0]
is being referenced even if contained in a
. How can I create a copy of the object a
in a way that even all its internal objects will not be referenced?