how to copy a dictionary
Gordon McMillan
gmcm at hypernet.com
Tue Jan 4 21:58:08 EST 2000
dictionaries have a copy() method.
Roy Smith asks:
> 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? --
> http://www.python.org/mailman/listinfo/python-list
- Gordon
More information about the Python-list
mailing list