copy method returns a duplicate shallow dictionary : Copy « Dictionary « Python Tutorial






x = {'username': 'admin', 'machines': ['foo', 'bar', 'baz']}
y = x.copy()

y['username'] = 'mlh'
y['machines'].remove('bar')
print y
print x








8.6.Copy
8.6.1.copy method returns a duplicate shallow dictionary