On Thu, Apr 30, 2015 at 9:15 AM, Ethan Furman <et...@stoneleaf.us> wrote:
> [...] > 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. > Why not? Unlike some other languages, Python does not have uniform priorities for unary operators, so it's reasonable for some unary operations to have a different priority than others, and certain things will be SyntaxErrors because of that. E.g. you can write "not -x" but you can't write "- not x". This is because they have different priorities: 'not' has a very low priority so it binds less tight than comparisons (which bind less tight than arithmetic), but '-' has a high priority. (There are other quirks, e.g. -2**2 means -(2**2) and you can write 2**-2; but you can't write 2**not x.) -- --Guido van Rossum (python.org/~guido)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com