This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author maxlem
Recipients maxlem
Date 2009-08-18.20:28:53
SpamBayes Score 0.0022832067
Marked as misclassified No
Message-id <1250627335.2.0.623159685079.issue6730@psf.upfronthosting.co.za>
In-reply-to
Content
Consider the following code sample :

keys = ['x', 'y', 'z']
d = dict.fromkeys(keys, [])
d['x'].append('dont')
d['y'].append('mix')
d['z'].append('me!')
print d['x']

>>> ['dont', 'mix', 'me!']

It is very unatural and dangerous to have all dict keys poining to the
same mutable object reference. 

The way it should behave : 
if value is mutable, create a new copy of value for each keys
else, it doesn't matter
History
Date User Action Args
2009-08-18 20:28:55maxlemsetrecipients: + maxlem
2009-08-18 20:28:55maxlemsetmessageid: <1250627335.2.0.623159685079.issue6730@psf.upfronthosting.co.za>
2009-08-18 20:28:53maxlemlinkissue6730 messages
2009-08-18 20:28:53maxlemcreate