On 06/03/2015 04:28 PM, sohcahto...@gmail.com wrote:

> 
> People actually argue that Python passes by value?  This is easily
> proven wrong by passing a mutable object to a function and changing
> it within the function.

Sure but if you reassign the variable that was passed it, it has no
effect whatsoever on the caller's variable, mutable or not.  This is why
people argue for "pass by value."  Because of this confusion, we often
say, "pass by object."

For example

def foo(bar):
    bar.append(5)
    bar = 6 #bar is no longer referring to a list

a=[1,2,3,4]
foo(a)
print (a)
# prints [1,2,3,4,5]






-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to