Skip to content

Instantly share code, notes, and snippets.

@joshz
Created November 16, 2011 20:55
Show Gist options
  • Save joshz/1371355 to your computer and use it in GitHub Desktop.
Save joshz/1371355 to your computer and use it in GitHub Desktop.
iterate over several dicts with no merging
from itertools import chain
for k,v in chain(d1.iteritems(), d2.iteritems(), d3.iteritems()):
do_some_stuff(k, v)
#or
ds = d1,d2,d3
for k,v in chain.from_iterable(d.iteritems() for d in ds):
do_some_stuff(k, v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment