title: Avoiding nested for loops
body: <p>I am trying to do some parameter testing on another code using python. I need to test 6 independent parameters, but I need all of the possible combinations of them. </p>
  
  <p>Each parameter has a minimum, a maximum, and a step value that needs to be passed to it. The first easy solution that popped into my head was a nested for loop structure that looked horrific, like this:</p>
  
  <pre><code>for var1 in xrange(min1,max1,step1):
      for var2 in xrange(min2,max2,step2):
          ...
              ...
                  ...
                      for var6 in xrange(min6,max6,step6):
                          '''
                          Do something and be icky in the process due
                          to being in the middle of six nested for loops
                          '''
  </code></pre>
  
  <p>I decided, no! This shall not stand. So I've been trying to work out a way to do this recursively, or at the very least, not nested six times. I can't really come up with a good scheme to do so. The biggest obstacle for me is that each variable has a different min, max, and step value.</p>
  
  <p>My thoughts so far aren't very helpful. I keep trying to make some recursive function work, but I just can't figure it out without nesting more for loops within the function. I've seen a lot of reference to itertools.product on here, but I can't quite figure out how to make that work either.</p>
  
  <p>Edit: What I'm doing is creating a directory named after the combination of the parameters, writing a file with those parameters, running another code with this file, and analyzing the output from that code. I am doing nothing in literally any of the for loops except for the final one. A lot of the parameters only have 2 values, some have 10, others have 3... it just kind of varies.</p>