Quote:
Originally Posted by DaWei
Arevos' point is that it isn't a copy, it's a reference to an immutable value, thus, if you reassign it in the function, you're reassigning the reference to another object, not reassigning the value of the original object. Consider this:
>>> def boogie (a):
... print a
... a = 5
... print a
... return a
...
>>> a = 10
>>> print boogie (a)
10
5
5
>>> a
10
>>>
|
In other words, the variable 'a' in the function stays local to the function, as long as variable 'a' is immutable like a number, string or tuple. Immutable parameters are passed by value.