I'd like to know an elegant, Pythonic way to iterate over a list of lists (or dict of lists) in parallel in Python 3. The number of lists is not known until runtime, so I believe I cannot simply supply them as arguments to the zip()
function.
For example, given the following data structure:
var = [['x1' ,'x2' ,'x3'], ['y1', 'y2', 'y3'], ['z1', 'z2', 'z3'], …]
I would like to be able to access the following values on each iteration:
x1,y1,z1
followed by x2,y2,z2
followed by x3,y3,z3
and so on.
Presumably I could achieve this using list indexes directly, or by using itertools.chain, but I'm looking for a more elegant approach using generators or otherwise.