A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-November/150733.html below:

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

[Python-Dev] Tricky way of of creating a generator via a comprehension expressionYury Selivanov yselivanov.ml at gmail.com
Wed Nov 22 19:00:36 EST 2017
On Wed, Nov 22, 2017 at 6:46 PM, Ivan Levkivskyi <levkivskyi at gmail.com> wrote:
[..]
> Just found another example of intuitive behaviour:
>
>>>> async def f():
> ...     for i in range(3):
> ...         yield i
> ...
>>>> async def g():
> ...     return [(yield i) async for i in f()]
> ...
>>>> g().send(None)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "<stdin>", line 2, in g
> TypeError: object async_generator can't be used in 'await' expression
>
> of course it is obvious for anyone who writes async code, but anyway an
> interesting example.

I wouldn't say that it's obvious to anyone...

I think this thread has started to discuss the use of 'yield'
expression in comprehensions, and the outcome of the discussion is
that everyone thinks that we should deprecate that syntax in 3.7,
remove in 3.8.  Let's start with that? :)

Yury
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4