replace dict contents

Andrew Bennetts andrew-pythonlist at puzzling.org
Tue Jul 27 04:16:23 EDT 2004


On Tue, Jul 27, 2004 at 08:56:35AM +0100, 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.

d1.clear()
d1.update(d2)

-Andrew.




More information about the Python-list mailing list