title: Python native coroutines and send()
body: <p>Generator based coroutines have a <code>send()</code> method which allow bidirectional communication between the caller and the callee and resumes a yielded generator coroutine from the caller. This is the functionality that turns generators into coroutines.</p>
  
  <p>While the new native <code>async/await</code> coroutines provide superior support for async I/O, I do not see how to get the equivalent of <code>send()</code> with them. The use of <code>yield</code> in <code>async</code> functions is explicitly forbidden, so native coroutines can return only once using a <code>return</code> statement. Although <code>await</code> expressions bring new values into a coroutine, those values come from callees, not the caller, and the awaited call is evaluated from the beginning each time, not from where it left off.</p>
  
  <p>Is there a way to resume a returned coroutine from where it left off and potentially send in a new value?
  How can I emulate the techniques in David Beazley's <a href="http://www.dabeaz.com/coroutines/" rel="noreferrer">Curious Course on Coroutines and Concurrency</a> using native coroutines?</p>
  
  <p>The general code pattern I have in mind is something like</p>
  
  <pre><code>def myCoroutine():
    ...
    while True:
      ...
      ping = yield(pong)
      ...
  </code></pre>
  
  <p>and in the caller</p>
  
  <pre><code>while True:
    ...
    buzz = myCoroutineGen.send(bizz)
    ...
  </code></pre>
  
  <hr>
  
  <h3>Edit</h3>
  
  <p>I accepted Kevin's answer but I have noticed that the PEP <a href="https://www.python.org/dev/peps/pep-0492/#id63" rel="noreferrer">says</a></p>
  
  <blockquote>
    <p>Coroutines are based on generators internally, thus they share the implementation. Similarly to generator objects, coroutines have throw() , send() and close() methods.</p>
  </blockquote>
  
  <p>...</p>
  
  <blockquote>
    <p>throw() , send() methods for coroutines are used to push values and raise errors into Future-like objects.</p>
  </blockquote>
  
  <p>So apparently native coroutines do have a <code>send()</code>? How does it work without <code>yield</code> expression to receive the values inside the coroutine?</p>