Keys = {"Status": True, ' name ': ' AAA '}
def fun1 (keys):
print ' fun1 '
print ' keys: ', keys
print ' keys Address ", ID (keys)
keys[' status ' = False
def fun2 (keys):
print ' fun2 '
print ' keys: ', keys
print ' Keys address ", ID (keys)
fun1 (keys)
fun2 (keys)
#fun1
#keys: {' status ': True, ' name ': ' AAA '}
# Keys address 49248184
#fun2
#keys: {' status ': False, ' name ': ' AAA '}
#keys address 49248184
From the results above, the dictionary passed in a reference, within which the value could be changed.
Look at the string below
str1= ' Hello World '
def fun1 (str1):
str1= "Ni hao"
print "fun1 str1:", STR1, "ID:", ID (str1)
print " STR1: ", STR1," ID: ", ID (str1)
fun1 (str1)
print" str1: ", STR1," ID: ", ID (str1)
#str1: Hello World id:39530
#fun1 Str1:ni Hao id:40521600
#str1: Hello World id:39530000
From the above, the string does not change after the function call, but it changes inside the function. So the corresponding tuple, numeric constants, are not going to change.