I read about itertools , which seems like a very powerful module. I am particularly interested in itertools.product() , which seems to give me all combinations of iterable inputs.
However, I would like to know which of the input iterations comes out of each output. For example, a simple standard example:
itertools.product([1, 2, 3], [1, 2])
If the user provided the inputs [1,2,3], [1, 2], I will not know in which order they entered, so getting the result
(1, 2)
doesn't really help, since I don’t know in what order they will be. Is there a way to provide input, for example:
itertools.product(foo = [1, 2, 3], bar = [1, 2])
and then getting outputs such as:
output['foo'] = 1 output['bar'] = 2
or
output.foo = 1 output.bar = 2
source share