replace dict contents
Tim Jarman
tmj at jarmania.com
Tue Jul 27 08:40:32 EDT 2004
On 27 Jul 2004, at 08:56, Robin Becker wrote:
> Is there a simple way to replace the contents of a dictionary entirely
> with those of another.
>
> for lists we can do
>
> L1[:] = L2
>
> but there doesn't seem to be an equivalent for dicts.
> --
> Robin Becker
> --
> http://mail.python.org/mailman/listinfo/python-list
>
How about:
>>> d1 = { "spam" : "eggs" }
>>> d2 = { "gumby" : "my brain hurts!"}
>>> d1 is d2
False
>>> d1 = dict(d2)
>>> d1
{'gumby': 'my brain hurts!'}
>>> d1 is d2
False
HTH
Tim J
More information about the Python-list
mailing list