Merge two objects in Python
If obj
is a dictionary, use its update
function:
obj.update(add_obj)
How about
merged = dict()
merged.update(obj)
merged.update(add_obj)
Note that this is really meant for dictionaries.
If obj
already is a dictionary, you can use obj.update(add_obj)
, obviously.