title: How to apply itertools.product to elements of a list of lists?
body: <p>I have a list of arrays and I would like to get the cartesian product of the elements in the arrays.</p>
  
  <p>I will use an example to make this more concrete...</p>
  
  <p>itertools.product seems to do the trick but I am stuck in a little detail.</p>
  
  <pre><code>arrays = [(-1,+1), (-2,+2), (-3,+3)];
  </code></pre>
  
  <p>If I do</p>
  
  <pre><code>cp = list(itertools.product(arrays));
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>cp = cp0 = [((-1, 1),), ((-2, 2),), ((-3, 3),)]
  </code></pre>
  
  <p>But what I want to get is</p>
  
  <pre><code>cp1 = [(-1,-2,-3), (-1,-2,+3), (-1,+2,-3), (-1,+2,+3), ..., (+1,+2,-3), (+1,+2,+3)].
  </code></pre>
  
  <p>I have tried a few different things:</p>
  
  <pre><code>cp = list(itertools.product(itertools.islice(arrays, len(arrays))));
  cp = list(itertools.product(iter(arrays, len(arrays))));
  </code></pre>
  
  <p>They all gave me <em>cp0</em> instead of <em>cp1</em>.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks in advance.</p>