On the input I have a list of ranges in the form (name, begin, end, step)
; the number of ranges is not known in advance. I could have two parameter ranges:
param_ranges = [ ("eye", 0, 5, 1), ("face", 2, 7, 2) ]
or three of them, etc:
param_ranges = [ ("eye", 0, 5, 1), ("face", 2, 7, 2), ("hair", 3, 10, 3) ]
I need to loop over all combinations of params. In the first example I should do:
for p1 in range(0, 5, 1):
for p2 in range(2, 7, 2):
# Put eye p1 on face p2
In the second example I should do:
for p1 in range(0, 5, 1):
for p2 in range(2, 7, 2):
for p3 in range(3, 10, 3):
# Put eye p1 on face p2 with hair p3
I cannot know in advance the number of the loops I would need because the length of param_ranges
depends on some inputs.
How do I arrange the generic nested loop on the unknown in advance number of variables that need to be looped over?