@@ -512,9 +512,24 @@ referenced.
512512
513513The actual parameters (arguments) to a function call are introduced in the local
514514symbol table of the called function when it is called; thus, arguments are
515- passed using *call by value * (where the *value * is always an object *reference *,
516- not the value of the object). [# ]_ When a function calls another function,
517- or calls itself recursively, a new
515+ always passed using *call by value *. For objects, that value is an object
516+ *reference *, not the value of the object itself. This means that mutations to
517+ a mutable object made inside the function are visible outside, but reassigning
518+ the parameter to a different object does not affect the caller::
519+
520+ >>> def try_to_modify(n, l):
521+ ... n = 42
522+ ... l.append(42)
523+ ...
524+ >>> num = 0
525+ >>> lst = []
526+ >>> try_to_modify(num, lst)
527+ >>> num
528+ 0
529+ >>> lst
530+ [42]
531+
532+ When a function calls another function, or calls itself recursively, a new
518533local symbol table is created for that call.
519534
520535A function definition associates the function name with the function object in
@@ -1151,6 +1166,4 @@ extracted for you:
11511166
11521167.. rubric :: Footnotes
11531168
1154- .. [# ] Actually, *call by object reference * would be a better description,
1155- since if a mutable object is passed, the caller will see any changes the
1156- callee makes to it (items inserted into a list).
1169+
0 commit comments