Skip to content

Instantly share code, notes, and snippets.

@NotTheEconomist
Created November 12, 2017 21:42
Show Gist options
  • Save NotTheEconomist/9570b85f8db6c766e360bdfcad1b66cb to your computer and use it in GitHub Desktop.
Save NotTheEconomist/9570b85f8db6c766e360bdfcad1b66cb to your computer and use it in GitHub Desktop.
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