In python, let's say I have three words:
d1, d2, d3 = {...}, {...}, {...}
I need to iterate over each of them and perform the same operation:
for k, v in d1.iteritems(): do_some_stuff(k, v) for k, v in d3.iteritems(): do_some_stuff(k, v) for k, v in d3.iteritems(): do_some_stuff(k, v)
Is there a way to do this in one loop so that each dictionary is repeated sequentially? Something like this, but the syntax here is clearly incorrect:
for k, v in d1.iteritems(), d2.iteritems(), d3.iteritems(): do_some_stuff(k, v)
I do not want to combine the dictionaries. The best I can think of is a nested loop below, but it seems like there should be a โmore pythonic, one loopโ.
for d in (d1, d2, d3): for k, v in d.iteritems(): do_some_stuff(k, v)