title: What is the purpose of the "send" function on Python generators?
body: <p>I understand <code>yield</code>. But what does a generator's <code>send</code> function do? The documentation says:</p>
  <blockquote>
  <pre><code>generator.send(value)
  </code></pre>
  <p>Resumes the execution and “sends” a value into the generator function. The <code>value</code> argument becomes the result of the current <code>yield</code> expression. The <code>send()</code> method returns the next value yielded by the generator, or raises <code>StopIteration</code> if the generator exits without yielding another value.</p>
  </blockquote>
  <p>What does that mean? I thought <code>value</code> was the input to the generator function? The phrase &quot;The <code>send()</code> method returns the next value yielded by the generator&quot; seems to be also the exact purpose of <code>yield</code>, which also returns the next value yielded by the generator.</p>
  <p>Is there an example of a generator utilizing <code>send</code> that accomplishes something <code>yield</code> cannot?</p>