On Wed, Apr 29, 2015 at 07:31:22PM -0700, Guido van Rossum wrote:
Ah, but here's the other clever bit: it's only interpreted this way *inside* a function declared with 'async def'. Outside such functions, 'await' is not a keyword, so that grammar rule doesn't trigger. (Kind of similar to the way that the print_function __future__ disables the keyword-ness of 'print', except here it's toggled on or off depending on whether the nearest surrounding scope is 'async def' or not. The PEP could probably be clearer about this; it's all hidden in the Transition Plan section.)
You mean we could write code like this?
def await(x): ...
if condition: async def spam(): await (eggs or cheese) else: def spam(): await(eggs or cheese)
I must admit that's kind of cool, but I'm sure I'd regret it.