[Python-Dev] Tricky way of of creating a generator via a comprehension expression (original) (raw)

Guido van Rossum guido at python.org
Sat Nov 25 18:37:12 EST 2017


On Sat, Nov 25, 2017 at 1:05 PM, David Mertz <mertz at gnosis.cx> wrote:

FWIW, on a side point. I use 'yield' and 'yield from' ALL THE TIME in real code. Probably 80% of those would be fine with yield statements, but a significant fraction use gen.send().

On the other hand, I have yet once to use 'await', or 'async' outside of pedagogical contexts. There are a whole lot of generators, including ones utilizing state injection, that are useful without the scaffolding of an event loop, in synchronous code.

Maybe you didn't realize async/await don't need an event loop? Driving an async/await-based coroutine is just as simple as driving a yield-from-based one (await does exactly the same thing as yield from).

But I won't argue with the usefulness of yield [from] in expressions. That is not the topic of this thread.

Of course, I never use them in comprehensions or generator expressions. And even after reading every post in this thread, the behavior (either existing or desired by some) such constructs have is murky and difficult for me to reason about. I strongly support deprecation or even just immediate SyntaxError in 3.7.

Maybe the rest of the discussion should be about deprecation vs. SyntaxError in Python 3.7.

-- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20171125/df6a9313/attachment.html>



More information about the Python-Dev mailing list