title: Why can I only use the await keyword inside of async function?
body: <p>Suppose I have code like this</p>
  
  <pre><code>async def fetch_text() -&gt; str:
      return "text "
  
  async def show_something():
      something = await fetch_text()
      print(something)
  </code></pre>
  
  <p>Which is fine. But then I want to clean the data, so I do</p>
  
  <pre><code>async def fetch_text() -&gt; str:
      return "text "
  
  def fetch_clean_text(text: str) -&gt; str:
      text = await fetch_text()
      return text.strip(text)
  
  async def show_something():
      something = fetch_clean_text()
      print(something)
  </code></pre>
  
  <p>(I could clean text inside <code>show_something()</code>, but let's assume that <code>show_something()</code> can print many things and doesn't or shouldn't know the proper way of cleaning them.)</p>
  
  <p>This is of course a <code>SyntaxError: 'await' outside async function</code>.  But—if this code could run—while the <code>await</code> expression is not placed inside a coroutine function, it is <em>executed</em> in the context of one. Why this behavior is not allowed?</p>
  
  <p>I see one pro in this design; in my latter example, you can't see that <code>show_something()</code>'s body is doing something that can result in its suspension. But if I were to make <code>fetch_clean_text()</code> a coroutine, not only would it complicate things but would probably also reduce performance. It just makes little sense to have another coroutine that doesn't perform any I/O by itself. Is there a better way?</p>