title: How to get Cartesian product in Python using a generator?
body: <p>I'm trying to get the Cartesian product of multiple arrays but the arrays are pretty large and I am trying to optimize memory usage. I have tried implementing a generator by using the below code but it just returns that there is a generator at a certain location. </p>
  
  <pre><code>import itertools
  
  x = [[1,2],[3,4]]
  
  def iter_tools(*array):
      yield list(itertools.product(*array))
  
  print(iter_tools(*x))
  </code></pre>
  
  <p>When I try the same code but with <code>return</code> instead of <code>yield</code> it works fine. How could I get the cartesian product by implementing a generator?</p>