title: How to make every combinaison of element from a list of n lists with m elements? (Python)
body: <p>From a list of n lists, each having different numbers of element, I want to get all possible combinaison.</p>
  
  <p>I make an example to help understand my problem:</p>
  
  <p>If I have a list of lists like this:</p>
  
  <pre><code>a = [['a','b'], ['c','d'],['e','f','g']]
  </code></pre>
  
  <p>I would like to get something like this:</p>
  
  <pre><code>[[('a', 'c', 'e')],
   [('a', 'c', 'f')],
   [('a', 'c', 'g')],
   [('a', 'd', 'e')],
   [('a', 'd', 'f')],
   [('a', 'd', 'g')],
   [('b', 'c', 'e')],
   [('b', 'c', 'f')],
   [('b', 'c', 'g')],
   [('b', 'd', 'e')],
   [('b', 'd', 'f')],
   [('b', 'd', 'g')]]
  </code></pre>
  
  <p>I get that with this:</p>
  
  <pre><code>list((zip(x,y,z) for x in a[0] for y in a [1] for z in a[2]))
  </code></pre>
  
  <p>Now I would like a function to do the same thing with any list of lists I pass too it. (No list is empty)</p>
  
  <p>Something recursive like <a href="https://stackoverflow.com/questions/7186518/function-with-varying-number-of-for-loops-python">that</a> can maybe work, but I have a hard time figure it out and something less complex and faster is maybe possible.</p>
  
  <p>I found a solution in java <a href="https://stackoverflow.com/questions/17169685/taking-one-element-from-each-list-in-every-possible-way">here</a>, but I don't know java and I can't translate it.</p>