Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The dictionary contains copy but NOT deep copy!

def f(**kw):
    print(kw)
    print(hex(id(kw['z'])))
    kw['z']['a'] = 7

z = {'a': 1, 'b': 2}
print(z)
print(hex(id(z)))
f(z = z)

print(z)

Output:

{'a': 1, 'b': 2}
0x7f01fd163180
{'z': {'a': 1, 'b': 2}}
0x7f01fd163180
{'a': 7, 'b': 2}