Changing argument value
flyfree
seungchan.oh at gmail.com
Thu Dec 13 16:43:23 EST 2007
>>> def fooA(y):
y = [3,4]
return y
>>> def fooB(y):
y[0] = 3
y[1] = 4
return y
>>> x = [1,2]
>>> fooA(x)
[3, 4]
>>> x
[1, 2]
>>> fooB(x)
[3, 4]
>>> x
[3, 4]
===============
>From above, the original argument value of fooA is same as before
[1,2]
but the original argument value of fooB is changed from [1,2] to
[3,4].
What is the difference between "y = [3,4]" and "y[0]=3
y[1] =4 "
Thanks,
SC
More information about the Python-list
mailing list