title: Python: calling 'list' on a map object twice
body: <p>I wanted to calculate the sum of squares up to n. Say n is 4. Then this code generates a list a map object in the range 0 to 4:</p>
  
  <pre><code>m = map(lambda x: x**2, range(0,4))
  </code></pre>
  
  <p>Ease enough. Now call list on m, and then sum:</p>
  
  <pre><code>&gt;&gt;&gt; sum(list(m))
  14
  </code></pre>
  
  <p>The unexpected behavior is that if I run the last line again, the sum is 0:</p>
  
  <pre><code>&gt;&gt;&gt; sum(list(m))
  0
  </code></pre>
  
  <p>I suspect that this is because calling <code>list(m)</code> returns an empty list, but I can't find an explanation for this behavior. Can someone help me out with this?</p>