I'm writing a for loop in Python and I'd like to iterate over a mix of single objects and flattened lists (or tuples) of objects.
For example:
a = 'one'
b = 'two'
c = [4, 5]
d = (10, 20, 30)
I'd like to iterate over all of these in a for loop. I was thinking a syntax like this would be elegant:
for obj in what_goes_here(a, b, *c, *d):
# do something with obj
I looked in itertools
for what_goes_here
and I didn't see anything, but I feel I must be missing something obvious!
The closest I found was chain but I'm wondering if anything exists that would leave my example unchanged (replacing what_goes_here
only).