dictmerge

Merge dicts without mutating them.


License
BSD-3-Clause
Install
pip install dictmerge==0.1.0

Documentation

dictmerge

Merge dicts without mutating them.

>>> d1 = {'a': 1}
>>> d2 = {'b': 2}
>>> dictmerge(d1, d2, moar=3)
{'a': 1, 'b': 2, 'moar': 3}

As of Python 3.5 you can use the following syntax for this purpose:

>>> d1 = {'a': 1}
>>> d2 = {'b': 2}
>>> {**d1, **d2}
{'b': 2, 'a': 1}
>>> {**d1, **d2, 'moar': 3}
{'b': 2, 'moar': 3, 'a': 1}

Installation

$ pip install dictmerge