A deep merge function for 🐍.
Project description
mergedeep
A deep merge function for 🐍.
Installation
$ pip install mergedeep
Usage
merge(target: Map[KT, VT], *sources: Map[KT, VT]) -> Map[KT, VT]
Deep merge without mutating the source dicts.
from mergedeep import merge
a = {"keyA": 1}
b = {"keyB": {"sub1": 10}}
c = {"keyB": {"sub2": 20}}
merged = merge({}, a, b, c)
print(merged)
# {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}}
Deep merge into an existing dict.
from mergedeep import merge
a = {"keyA": 1}
b = {"keyB": {"sub1": 10}}
c = {"keyB": {"sub2": 20}}
merge(a, b, c)
print(a)
# {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}}
License
MIT © Travis Clarke
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mergedeep-1.0.0.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for mergedeep-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f76b1ce02e87b99a2e12f2955736e6a2233d59bd07271530e35357558395aefe |
|
MD5 | a242bbdac6130c6aa7d350abb1ffac7f |
|
BLAKE2b-256 | 85e9ced5a2103777992ec818c481aabe54bbf3cb3261d6fee5ef024c1b931993 |