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

Ethan Furman ethan at stoneleaf.us
Sun Nov 26 02:13:09 EST 2017


On 11/25/2017 04:20 PM, David Mertz wrote:

On Sat, Nov 25, 2017 at 3:37 PM, Guido van Rossum wrote:

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). I realize I can, but it seems far from straightforward. I guess this is really a python-list question or something, but what is the async/await spelling of something toy like: In [1]: def fib(): ...: a, b = 1, 1 ...: while True: ...: yield a ...: a, b = b, a+b ...: In [2]: from itertools import takewhile In [3]: list(takewhile(lambda x: x<200, fib())) Out[3]: [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]

Maybe the rest of the discussion should be about deprecation vs. SyntaxError in Python 3.7. I vote SyntaxError, of course. :-)

Given the recent thread about the difficulty of noticing DeprecationWarnings, I also vote SyntaxError.

On the other hand, if we have a change in 3.7 about the visibility of DeprecationWarnings, this would make an excellent test case.

-- Ethan



More information about the Python-Dev mailing list