NOTE: corrected question!
It is well-known that itertools
allows for easy creation of nested for
loops using itertools.product
. But the following is what I want and can't do yet. Using
lfl = int(input( "length of first loop: "))
nol = int(input( "number of loops: "))
Causing:
- length of loop: 12
- number of loops: 4
I want an equivalent to:
for i1 in range(1,12):
for i2 in range(i1,12):
for i3 in range(i2,12):
for i4 in range(i3,12):
function(i1,i2,i3,i4)
itertools.product
does way to many.
Or the more general question where nol
causes the creating of func_1(x), func_2(x,y), .... func_nol-1(x,y,...) and the code needs to be equivalent to:
for i1 in range(1,12):
for i2 in range(func_1(i1),12):
for i3 in range(func_2(i1,i2),12):
for i4 in range(func_3(i1,i2,i3),12):
function(i1,i2,i3,i4)
And one more further generalization would be
for i1 in range(1,12):
for i2 in range(start_func_1(i1, *global),end_func_(12, *global)):
for i3 in range(start_func_2(i1,i2,*global),end_func_2(12,*global):
for i4 in range(start_func_3 etc....