title: In Python, whats the difference between a list comprehension with a list and a tuple?
body: <p>Playing around with iPython, I was surprised to discover that given a list <code>f</code> of objects each supporting some method <code>x()</code> (that, say, prints out <code>"Hi!"</code>), the expression:</p>
  
  <pre><code>(y.x() for y in f)
  </code></pre>
  
  <p>is not semantically equivalent to</p>
  
  <pre><code>[y.x() for y in f]
  </code></pre>
  
  <p>The first one (with the tuple as output) results in a generator expression that is not evaluated unless I iterate over it, whereas the one with the list actually causes the generation to happen immediately:</p>
  
  <pre><code>In [30]: (y.x() for y in f)
  Out[30]: &lt;generator object &lt;genexpr&gt; at 0x2d78d70&gt;
  </code></pre>
  
  <p>but</p>
  
  <pre><code>In [31]: [y.x() for y in f]
  Hi!
  Hi!
  Hi!
  Hi!
  </code></pre>
  
  <p>This seems rather counter-intuitive.</p>
  
  <p>Question: Why is the first expression not generating a tuple of the values obtained from the generator the way the list is being built?</p>
  
  <hr>
  
  <p><strong>Update</strong>:  As I stare at this more, I realize that perhaps what's happening in the first case is that Python is just building a tuple containing a generator rather than evaluating the generator as it is in the second case.</p>
  
  <p>So is it true that it is not possible to <em>directly</em> get a tuple as the result of generating a list comprehension? (I understand I can do <code>tuple([y.x() for y in f])</code>). I don't have a use case, this is purely for my understanding.</p>