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 awaitable

Parameters & Attributes

NameTypeDescription
awaitableexpressionObject 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()))
Python Reference