title: Unexpected behaviour with a conditional generator expression
body: <p>I was running a piece of code that unexpectedly gave a logic error at one part of the program. When investigating the section, I created a test file to test the set of statements being run and found out an unusual bug that seems very odd.</p>
  
  <p>I tested this simple code:</p>
  
  <pre><code>array = [1, 2, 2, 4, 5] # Original array
  f = (x for x in array if array.count(x) == 2) # Filters original
  array = [5, 6, 1, 2, 9] # Updates original to something else
  
  print(list(f)) # Outputs filtered
  </code></pre>
  
  <p>And the output was:</p>
  
  <pre><code>&gt;&gt;&gt; []
  </code></pre>
  
  <p>Yes, nothing. I was expecting the filter comprehension to get items in the array with a count of 2 and output this, but I didn't get that:</p>
  
  <pre><code># Expected output
  &gt;&gt;&gt; [2, 2]
  </code></pre>
  
  <p>When I commented out the third line to test it once again:</p>
  
  <pre><code>array = [1, 2, 2, 4, 5] # Original array
  f = (x for x in array if array.count(x) == 2) # Filters original
  ### array = [5, 6, 1, 2, 9] # Ignore line
  
  print(list(f)) # Outputs filtered
  </code></pre>
  
  <p>The output was correct (you can test it for yourself):</p>
  
  <pre><code>&gt;&gt;&gt; [2, 2]
  </code></pre>
  
  <p>At one point I outputted the type of the variable <code>f</code>:</p>
  
  <pre><code>array = [1, 2, 2, 4, 5] # Original array
  f = (x for x in array if array.count(x) == 2) # Filters original
  array = [5, 6, 1, 2, 9] # Updates original
  
  print(type(f))
  print(list(f)) # Outputs filtered
  </code></pre>
  
  <p>And I got:</p>
  
  <pre><code>&gt;&gt;&gt; &lt;class 'generator'&gt;
  &gt;&gt;&gt; []
  </code></pre>
  
  <p>Why is updating a list in Python changing the output of another generator variable? This seems very odd to me.</p>