Language Syntax
Await expression — Python syntax
Suspend a coroutine until the awaitable produces a result or raises. Await is legal in an async function (ordinary script grammar); the operand must implement an awaitable protocol. Await does not itself guarantee concurrent execution. An interactive environment can support top-level await through special compilation flags; ordinary scripts cannot.
Formal Syntax & Structure
python syntaxpython
await awaitableParameters & Attributes
| Name | Type | Description |
|---|---|---|
| awaitable | expression | Object supporting await. |
Return Value
object
Value obtained by evaluating this expression; see description for context and constraints.
Working Example
Example Snippetpython
import asyncioasync def get(): return 5async def main(): return (await get())+2print(asyncio.run(main()))