a = 1 b = 3 - 2 a is b # True
a and b are (coincidentally) references to the same int object with value 1.
a = a + 1 a is b # False (b still points to the int(1))
In perl = defines or redefines. In python it associates. A variable name on the left of an = forgets everything it knew and points to the new object.
b += 1 a is b #True a = ['something', 'else'] b = a b.append('entirely') print a # ['something', 'else', 'entirely']
Ints are immutable, which makes passing ints by reference very close to passing by value.
Lists are mutable, so operations on one reference are reflected in others.