Question about Pass-by-object-reference?

fl rxjwg98 at gmail.com
Tue Jul 22 21:04:09 CEST 2014


Hi,
I learn Python function call on tutorial. There is a link on this subject.
http://robertheaton.com/2014/02/09/pythons-pass-by-object-reference-as-explained-by-philip-k-dick/

Although it explains clearly, the figure makes me puzzled.

""Python is different. As we know, in Python, "Object references are passed by 
value".

A function receives a reference to (and will access) the same object in memory as
used by the caller. However, it does not receive the box that the caller is
storing this object in; as in pass-by-value, the function provides its own box and
creates a new variable for itself. Let's try appending again:""

On the figure, it shows that the result is [0, 1]  (Am I right on the figure?)


When I enter the command lines on my computer:
>>> list=[0]
>>> append(list)
>>> print(list)
[0]

How to understand my result and that figure?



Thanks,



More information about the Python-list mailing list