pep-0492: Explain why "async def" and not "def async".

This commit is contained in:
Yury Selivanov 2015-04-23 14:20:41 -04:00
parent d5c4d8ac67
commit d0d589154f
1 changed files with 16 additions and 0 deletions

View File

@ -884,6 +884,22 @@ stating that the statement is asynchronous. It is also more consistent
with the existing grammar.
Why "async def" and not "def async"
-----------------------------------
``async`` keyword is a *statement qualifier*. A good analogy to it are
"static", "public", "unsafe" keywords from other languages. "async
for" is an asynchronous "for" statement, "async with" is an
asynchronous "with" statement, "async def" is an asynchronous function.
Having "async" after the main statement keyword might introduce some
confusion, like "for async item in iterator" can be read as "for each
asynchronous item in iterator".
Also, "async def" better separates coroutines from regular functions
visually.
Why not a __future__ import
---------------------------