A three-liner to combine or merge two dictionaries:
dest = {}
dest.update(orig)
dest.update(extra)
This creates a new dictionary dest
without modifying orig
and extra
.
Note: If a key has different values in orig
and extra
, then extra
overrides orig
.