title: Is there a way to call await directly in Jupyter cell?
body: <p>I've seen examples of such code working in certain environments (eg <a href="https://github.com/ipython/ipykernel/pull/323" rel="nofollow noreferrer">https://github.com/ipython/ipykernel/pull/323</a>).</p>
  
  <p>But for me this only raises <code>SyntaxError</code> so far:</p>
  
  <p><a href="https://i.stack.imgur.com/Hsj13.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hsj13.png" alt="enter image description here"></a></p>
  
  <p><strong>Update:</strong></p>
  
  <p>I know that in "pure" python it won't work and <code>await</code> is supposed to be used in <code>async def</code>'s only.</p>
  
  <p>I also know that in jupyter it <em>is</em> possible (see link above) so the engine is capable of doing this. The question is how to get rid of this error message.</p>
  
  <p><strong>Update2</strong>
  What's the idea of calling await directly:</p>
  
  <p>I'm working with an async library. In current version of jupyter it's hard to get the return value of a coroutine:</p>
  
  <p><a href="https://i.stack.imgur.com/jdLz8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jdLz8.png" alt="enter image description here"></a>
  The best thing I've come up to is through global variables:</p>
  
  <p><a href="https://i.stack.imgur.com/WBHiW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WBHiW.png" alt="enter image description here"></a></p>
  
  <p>One of the problems here is that <code>res</code> is not ready in the cell 25 yet. I have to wait until I see "done", then use the value in the another cell.</p>
  
  <p>Another problem is semantic asymmetry between calling a coroutine from the cell directly and from another coroutine, which is pretty irrelevant when writing scripts in an editor, but quite crucial for repl.</p>
  
  <p><em>Now</em> consider this:</p>
  
  <p><a href="https://i.stack.imgur.com/7RPH8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7RPH8.png" alt="enter image description here"></a></p>