Why does the variable L gets manipulated in the sorting(L)
function call? In other languages, a copy of L would be passed through to sorting()
as a copy so that any changes to x
would not change the original variable?
def sorting(x):
A = x #Passed by reference?
A.sort()
def testScope():
L = [5,4,3,2,1]
sorting(L) #Passed by reference?
return L
>>> print testScope()
>>> [1, 2, 3, 4, 5]