On 11/24/2017 04:22 PM, Guido van Rossum wrote:
The more I hear about this topic, the more I think that `await`, `yield` and
`yield from` should all be banned from
occurring in all comprehensions and generator expressions. That's not much
different from disallowing `return` or `break`.
For me, the deciding factor would be the the affect upon:
1) the containing function (if any); and
2) the result of the genexp/comprehension
I think of generator expressions / comprehensions as self-contained units of code that will have no (side-)effects upon
the containing function and/or surrounding code (and a containing function is not necessary), and that each will return
the type expressed by the syntax.
In other words:
[ l for l in ...] -> list
{s for s in ...] -> set
{k:v for k, v in ...] -> dict
(g for g in ...] -> genexp
Since 'yield' and 'yield from' invalidate those, I'm in favor of declaring them
syntax errors.
If 'await' does not invalidate the above constraints then I'm fine with
allowing them.
--
~Ethan~
_______________________________________________
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