[ 'spamarguments assigned references to objects changes local name' value only changes shared object in place [ changer(xlxl ( ['spam' ]callerpass immutable and mutable objects is unchangedl is differentin this codethe changer function assigns values to argument itselfand to component of the object referenced by argument these two assignments within the function are only slightly different in syntax but have radically different resultsbecause is local variable name in the function' scopethe first assignment has no effect on the caller--it simply changes the local variable to reference completely different objectand does not change the binding of the name in the caller' scope this is the same as in the prior example argument is local variable nametoobut it is passed mutable object (the list that references in the caller' scopeas the second assignment is an in-place object changethe result of the assignment to [ in the function impacts the value of after the function returns reallythe second assignment statement in changer doesn' change --it changes part of the object that currently references this in-place change impacts the caller only because the changed object outlives the function call the name hasn' changed either --it still references the samechanged object--but it seems as though differs after the call because the value it references has been modified within the function in effectthe list name serves as both input to and output from the function figure - illustrates the name/object bindings that exist immediately after the function has been calledand before its code has run if this example is still confusingit may help to notice that the effect of the automatic assignments of the passed-in arguments is the same as running series of simple assignment statements in terms of the first argumentthe assignment has no effect on the callerx print( they share the same object resets 'aonly'xis still the assignment through the second argument does affect variable at the callthoughbecause it is an in-place object changel [ [ 'spamprint( ['spam' they share the same object in-place change'lsees the change too argument-passing basics