title: Converting iterator to list changes the iterator
body: <p>The following code produces some very strange results</p>
  
  <pre><code>import re
  string = "test test test"
  positions = re.finditer("test", string)
  print (list(positions))
  print (list(positions))
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>[&lt;Match object...&gt;, &lt;Match object...&gt;, &lt;Match object...&gt;]
  []
  </code></pre>
  
  <p>Now, I think I know what's going on here. The first <code>list</code> call "exhausts" the iterator (so it "uses the iterator up", like in a generator, in the process of creating a list from the iterator) so then when the second call to <code>list</code> is made, the iterator is gone and we get an empty list. This seems to be confirmed by the paragraph below, although I am am trying to understand some of the things they are saying here, so I am not entirely happy with this explanation (if it is the right one):</p>
  
  <blockquote>
    <p>A container object (such as a list) produces a fresh new iterator
    each time you pass it to the iter() function or use it in a for loop.
    Attempting this with an iterator will just return the same exhausted
    iterator object used in the previous iteration pass, making it appear
    like an empty container.</p>
  </blockquote>
  
  <p>The above paragraph is from <a href="https://docs.python.org/3/glossary.html#term-iterator" rel="nofollow">the official documentation</a>. </p>
  
  <p>I do not really understand what they are saying in the first sentence in the above paragraph, especially with regards to passing to the <code>iter()</code> function, and I do not know how they connect usage in a for loop to a list producing a fresh new iterator. The second sentence, though, seems closer to what I first thought was going on in the code above. </p>
  
  <p>If anyone can help me clear up the confusion here, I would appreciate it immensely.</p>
  
  <p><strong>NOTE:</strong></p>
  
  <p>I am using Python 3.5.1</p>