Re: [Python-Dev] Tricky way of of creating a generator via a comprehension expression

2017年11月25日 23:15:07 -0800

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~
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to