del d deletes the variable d , but the object to which it refers will continue to exist if there are other references. You don't need a dictionary to watch this:
>>> d = {i:i for i in range(5)} >>> dd = d >>> d['x'] = 'x' >>> del d >>> d Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'd' is not defined >>> dd {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 'x': 'x'}
(The string d['x']='x' shows that dd=d does not copy the dictionary itself, but makes only an additional reference.)
Also compare the clear behavior that modifies the actual object:
>>> d = {i:i for i in range(5)} >>> k = d.keys() >>> del d >>> list(k) [0, 1, 2, 3, 4] >>> d = {i:i for i in range(5)} >>> k = d.keys() >>> d.clear() >>> list(k) []
source share