title: Python: generator expression vs. yield
body: <p>In Python, is there any difference between creating a generator object through a <strong>generator expression</strong> versus using the <strong>yield</strong> statement?</p>
  <p>Using <em>yield</em>:</p>
  <pre><code>def Generator(x, y):
      for i in xrange(x):
          for j in xrange(y):
              yield(i, j)
  </code></pre>
  <p>Using <em>generator expression</em>:</p>
  <pre><code>def Generator(x, y):
      return ((i, j) for i in xrange(x) for j in xrange(y))
  </code></pre>
  <p>Both functions return generator objects, which produce tuples, e.g. (0,0), (0,1) etc.</p>
  <p>Any advantages of one or the other? Thoughts?</p>