Passing is always by reference. Python has a concept of mutable vs immutable datatypes. List is mutable, tuple is not. int, float, bool, string are immutable too. You can not modify a immutable object.
a = 5 # a is pointing to immutable object int(5)
a = a + 1 # a is not pointing to a immutable object object int(6)
Callee passes 5 by reference, function gets the location of object int(5), but the function pointed the local variable a to a new location, int(6), and callee was not notified. Hope it clears up things.
Submitted by Amit Upadhyay (not verified) on Fri, 10/03/2006 - 23:27.
Passing is always by reference. Python has a concept of mutable vs immutable datatypes. List is mutable, tuple is not. int, float, bool, string are immutable too. You can not modify a immutable object.
a = 5 # a is pointing to immutable object int(5)
a = a + 1 # a is not pointing to a immutable object object int(6)
Callee passes 5 by reference, function gets the location of object int(5), but the function pointed the local variable a to a new location, int(6), and callee was not notified. Hope it clears up things.
Submitted by Amit Upadhyay (not verified) on Fri, 10/03/2006 - 23:27.