Clarification on python intro
Alan Garrison
aeg@lbwl.com
Tue, 09 May 2000 09:58:43 -0400
Hmmm... the carriage returns got garbled (I blame GroupWise).
Maybe this will clean it up.
>>> # create three local lists (mutable objects)
>>> loc1 = [1,2,3]>>> loc2 = ["a","b","c"]
>>> loc3 = ["d","e","f"]
>>> # create function to test mutability
>>> def Dinsdale(arg1,arg2,arg3):
... arg1[0] = "99" # first, change indexed value
... arg1 = ["spam", "SPAM", "SPAM!!!"] # second, create new list
... arg2 = [44,45,46] # first, create new list instance
... arg2[0] = 55 # second, change indexed value
... arg3 = "Assigning the argument to be a new type"
...
>>> Dinsdale(loc1,loc2,loc3) # call function with our locals
>>> print loc1 # should have [0] index changed
['99', 2, 3]
>>> print loc2 # should not change
['a', 'b', 'c']
>>> print loc3 # should not change
['d', 'e', 'f']
>>>
Better?