consider the following code
#! /usr/bin/env python
my_dict = {1:['Bernd','das','Brot'], 2:['Chili','das','Schaf'], 3:['Briegel','der','Busch']}
print my_dict
chili = my_dict[2]
print chili
del chili[2]
print chili
print my_dict
which produces the following output with my Python 2.7.5:
{1: ['Bernd', 'das', 'Brot'], 2: ['Chili', 'das', 'Schaf'], 3: ['Briegel', 'der', 'Busch']}
['Chili', 'das']
{1: ['Bernd', 'das', 'Brot'], 2: ['Chili', 'das'], 3: ['Briegel', 'der', 'Busch']}
As you can see, the list in the dict was also manipulated, so they appear to point to the same object/thing in memory.
Maybe I understand a basic Python principle wrong here (feel free to flame & point me towards the spec), but is this intended behaviour? And if it is, is there a way to delete and entry by index from a list taken from a dict without manipulating the original dict? Quite often I find out there is already an extraordinary simple Python way for doing stuff I try to accomplish with complicated code constructs.
I have a large dict here and I take lists out of it quite often, and I don't want to rebuild the dict each time I process the list in any way.
Thank you very much for your time & help,
Tobias