title: Problem with iterating generator functions
body: <p>Let's say we have this generator function:</p>
  
  <pre><code>def count_up_to(max):
      count = 1
      while count &lt;= max:
          yield count
          count += 1
  </code></pre>
  
  <p>Now if I want to call the <code>next()</code> function, I will have to  assign the <code>count_up_to</code> function to a variable, otherwise the output will always be "1".</p>
  
  <p>The code below works fine and iterates through the numbers:</p>
  
  <pre><code>counter = count_up_to(10)
  print(next(counter))
  print(next(counter))
  print(next(counter))
  .
  .
  .
  </code></pre>
  
  <p>But this one does not work and keeps printing "1".</p>
  
  <pre><code>print(next(count_up_to(10)))
  print(next(count_up_to(10)))
  print(next(count_up_to(10)))
  .
  .
  .
  </code></pre>
  
  <p>But why? is <code>print(next(counter))</code> any different from <code>print(next(count_up_to(10)))</code> ?!</p>