Language Syntax

Async def — Python syntax

Define a coroutine function unless its body contains yield, in which case it defines an asynchronous generator function. Calling a coroutine function returns a coroutine, whose body runs when awaited or scheduled.

Formal Syntax & Structure

python syntaxpython
async def name(parameters):    suite

Working Example

Example Snippetpython
import asyncioasync def total():    return 7print(asyncio.run(total()))
Python Reference