在C++里pass by value和pass by reference是兩個(gè)很容易區(qū)分的東西。但是在python中,讓我有點(diǎn)糊涂,其實(shí)Python是“pass by assignment”。

舉個(gè)例子:
>>> a=[1,2,3]
>>> b=a
>>> b
[1, 2, 3]
>>> a.append(4)
>>> b
[1, 2, 3, 4]
>>> a=[1]
>>> b
[1, 2, 3, 4]
可以看到,a和b一開始都是bind to [1,2,3]這一個(gè)list object。這個(gè)list object的變化(append 4)使得a和b都發(fā)生了變化。但是,當(dāng)a bind to another object [1], b is still pointing to the original object, and the original object doesn't change.
This property properly determines when calling a function, how the parameter is passed. Personally I would understand that as "pass by object".
Reference
stack overflow and quora