Now I am learning python from the Mark Lutz book. And there chapter 11 deals with assignment instructions. And I had some misunderstanding. The book is written.
The assignment instruction creates an object reference . As mentioned in Chapter 6, in Python, the assignment statement stores references to objects in variables or elements of data structures. They always create object references and never create copies of objects. Because of this, variables in Python look more like pointers than data storage areas.
But here is a counterexample, if you touch the lists:
>>> a = [1,2,3] >>> a [1, 2, 3] >>> b = a >>> b [1, 2, 3] >>> a = a + a >>> b [1, 2, 3] >>> a [1, 2, 3, 1, 2, 3]
As you can see, b has not changed, so in this operation >>> b = a a copy was made of a, and not a pointer to a.
Same here:
>>> k = 10 >>> l = k >>> k = 20 >>> k 20 >>> l 10
I, apparently, something not understand?