how to copy a dictionary

Roy Smith roy at popmail.med.nyu.edu
Tue Jan 4 21:01:54 EST 2000


If I do:

d = {'hedgehog': 'spiney norman'}
temp = d
temp['scotsman'] = 'earnest potgorney'

I end up changing the original dictionary, d.  It's obvious that what's 
going on is when I do temp = d I get a pointer to the same object 
instead of a new object.  My question is, how do I force a new object to 
be created, so when  modify it, I don't also modify the original?



More information about the Python-list mailing list