Skip to content

Instantly share code, notes, and snippets.

View pleasantone's full-sized avatar

Paul Traina pleasantone

View GitHub Profile
@pleasantone
pleasantone / remerge.py
Last active February 24, 2017 16:36 — forked from mahmoud/remerge.py
Recursively merging dictionaries with boltons.iterutils.remap. Useful for @hynek's configs. https://twitter.com/hynek/status/696720593002041345
"""
This comes from Mahmoud Hashemi @mhashemi found at:
https://gist.github.com/mahmoud/db02d16ac89fa401b968
This is an extension of the technique first detailed here:
http://sedimental.org/remap.html#add_common_keys
In short, it calls remap on each container, back to front, using the accumulating
previous values as the default for the current iteration.