I have a nested loop, which will assemble all variations of params. the more params, the bigger the nesting will become.
for param1 in [1,2,3]:
for param2 in [5,10,15]:
for param3 in [10,11,12]:
for param4 in [35,36,37]:
for param5 in [2,4,6]:
params = {
'param1': param1,
'param2': param2,
'param3': param3,
'param4': param4,
'param5': param5,
}
run_test(params)
To make the code a bit more readable, want to put all variations into a dict, and then create the loop above. but how to achieve this?
configuration = {
'param1': [1,2,3],
'param2': [5,10,15],
'param3': [10,11,12],
'param4': [35,36,37],
'param5': [2,4,6],
}
Desired output is a list of dicts
[
{
'param1': param1,
'param2': param2,
'param3': param3,
'param4': param4,
'param5': param5,
},
{ next dict …}
]
The Cartesian product would to work if the input is a list of lists
, but i have an input which is a dict of lists
Suggestions on how to improove the first solution this are highly welcome