title: All possible permutations of a set of lists in Python
body: <p>In Python I have a list of n lists, each with a variable number of elements. How can I create a single list containing all the possible permutations: </p>
  
  <p>For example</p>
  
  <pre><code>[ [ a, b, c], [d], [e, f] ]
  </code></pre>
  
  <p>I want </p>
  
  <pre><code>[ [a, d, e] , [a, d, f], [b, d, e], [b, d, f], [c, d, e], [c, d, f] ]
  </code></pre>
  
  <p>Note I don't know n in advance. I thought itertools.product would be the right approach but it requires me to know the number of arguments in advance</p>