I want to do something like this:
merge({'a': 1}, {'b': 2})
and get a return of {'a': 1, 'b':2}
.
.update()
, which sadly doesn't return the updated or a new dict
, just None
(why?.....)..update()
, I could write a 3 line function for this. I don't, I just want an already existing/known package that do this kind of job in a simple way.This edit is just to explain the lovely SO users that this is not a duplicate of How to merge two Python dictionaries in a single expression? and hence the chosen answer is unrelated with any of the answers provided in the candidate duplicate.
The package dictmerge
can merge dictionaries.
As of Python 3.5 you can merge dictionaries without an additional package:
>>> d1 = {'a': 1}
>>> d2 = {'b': 2}
>>> {**d1, **d2}
{'b': 2, 'a': 1}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments