Created
November 12, 2017 21:42
-
-
Save NotTheEconomist/9570b85f8db6c766e360bdfcad1b66cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def combine_dicts(a, b, *, op=lambda x: x, default=None): | |
result = {} | |
for k, va in a.items(): | |
vb = b.get(k, default) | |
result[k] = op(va, vb) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment