[Python-Dev] PEP 492 vs. PEP 3152, new round

Ethan Furman ethan at stoneleaf.us
Thu Apr 30 18:15:41 CEST 2015


On 04/29, Yury Selivanov wrote:

> Because you want operators to be resolved in the
> order you see them, generally.
> 
> You want '(await -fut)' to:
> 
> 1. Suspend on fut;
> 2. Get the result;
> 3. Negate it.
> 
> This is a non-obvious thing. I would myself interpret it
> as:
> 
> 1. Get fut.__neg__();
> 2. await on it.

Both you and Paul are correct on this, thank you.  The proper resolution
of

  await -coro() 

is indeed to get the result of coro(), call it's __neg__ method, and then
await on that.

And that is perfectly reasonable, and should not be a SyntaxError; what it
might be is an AttributeError (no __neg__ method) or an AsyncError (__neg__
returned non-awaitable object), or might even just work [1]... but it
definitely should /not/ be a SyntaxError.

--
~Ethan~

[1] http://stackoverflow.com/q/7719018/208880


More information about the Python-Dev mailing list