I have a function that takes a list or numpy array v. The function modify v so also the original vector x changes (because of curse this is a reference). I would like to have the old value of x. There are some easy solutions to this but they do not look very elegant.
What is the most pythonic way to solvethis problem?
Let consider for example
def change_2(v):
v[2]=6
return v
x=[1,2,3]
z=change_2(x)
print "x=", x,"z=",z
x= [1, 2, 6] z= [1, 2, 6] #I would like x=[1, 2, 3]