On 23 November 2017 at 01:00, Yury Selivanov <yselivanov.ml@gmail.com> wrote:
On Wed, Nov 22, 2017 at 6:46 PM, Ivan Levkivskyi <levkivskyi@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? :)

I am not sure everyone agrees with this. My main obstacle is following, consider motivation for the `await` part of PEP 530
which is in my understanding is roughly like this:

"People sometimes want to refactor for-loops containing `await` into a comprehension but that doesn't work (particularly because of the hidden function scope) - lets fix this"

I don't see how this compare to:

"People sometimes want to refactor for-loops containing `yield` into a comprehension but that doesn't work (particularly because of the hidden function scope) - lets make it a SyntaxError"

--
Ivan