replace dict contents

Duncan Booth me at
Tue Jul 27 10:20:15 CEST 2004

Robin Becker <robin at> wrote in 
news:41060AB3.9080600 at

> 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.

The simplest would seem to be


although, this doesn't have the flexibility of a single assignment so you 
can't use it where 'd2' is actually an expression involding d1.

More information about the Python-list mailing list