Skip to content

Instantly share code, notes, and snippets.

@liluo
Created March 2, 2012 11:16
Show Gist options
  • Save liluo/1957856 to your computer and use it in GitHub Desktop.
Save liluo/1957856 to your computer and use it in GitHub Desktop.
r1 = {'a': {'q': 1, 'w': 2}, 'b': {'q': 3, 'w': 4}}
r2 = {'a': {'q': 5, 'w': 7}, 'b': {'q': 8, 'w': 2}}
# ret = {'a': {'q': 6, 'w': 9}, 'b': {'q': 11, 'w': 6}}
a = lambda x, y: list(zip(x.keys(), list(zip(x.values(), y.values()))))
rs = reduce(a, (r1, r2))
print rs
#print reduce(a, map(lambda r: r[1], rs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment