The chapter discusses cloning of mutable types (shallow and deep copy), but what about deleting variables and items? Does deleting a copy have no effect on the original? This is a case where Python conforms to intuition. The del command (or other techniques, like mutating methods and slice assignments) do not remove original references.

In this example, there are two situations. First, variables A and B are aliases to the same dictionary. When an item of one is deleted, that change immediate can be seen by the alias. Second, the program deletes variable A. However, B remains intact.


Deleting Aliases

A = B = list(range(10,20,3))
del A[0]
print B
del B
print A