I'm looking for an 'efficient' way in Python 3.x
to create various nested loops, and then append the result of each inner loop (a multi-dimensional array).
For instance, the function model_A()
has 3 parameters (a
, b
, c
), and I want to enumerate all of the possibilities to test the model. The casual way is:
result_a = []
for a_value in a:
result_a_b = []
for b_value in b:
result_a_b_c = []
for c_value in c:
result = model_A(a, b, c)
result_a_b_c.append(result)
result_a_b.append(result_a_b_c)
result_a.append(result_a_b)
I think there should be a way to 'efficiently' create the nested loop, and append the result, without having to create an empty list before each loop, and append the result at the end of each inner loop.