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

Yury Selivanov yselivanov.ml at gmail.com
Sat Nov 25 12:21:08 EST 2017


So we are keeping asynchronous generator expressions as long as they are
defined in an 'async def' coroutine?

Yury

On Sat, Nov 25, 2017 at 12:17 PM Brett Cannon <brett at python.org> wrote:

>
>
> On Fri, Nov 24, 2017, 19:32 Guido van Rossum, <guido at python.org> wrote:
>
>> On Fri, Nov 24, 2017 at 4:22 PM, Guido van Rossum <guido at python.org>
>> wrote:
>>
>>> The more I hear about this topic, the more I think that `await`, `yield`
>>> and `yield from` should all be banned from occurring in all comprehensions
>>> and generator expressions. That's not much different from disallowing
>>> `return` or `break`.
>>>
>>
>> From the responses it seems that I tried to simplify things too far.
>> Let's say that `await` in comprehensions is fine, as long as that
>> comprehension is contained in an `async def`. While we *could* save `yield
>> [from]` in comprehensions, I still see it as mostly a source of confusion,
>> and the fact that the presence of `yield [from]` *implicitly* makes the
>> surrounding `def` a generator makes things worse. It just requires too many
>> mental contortions to figure out what it does.
>>
>> I still propose to rule out all of the above from generator expressions,
>> because those can escape from the surrounding scope.
>>
>
> +1 from me.
>
> -Brett
>
>
>> --
>> --Guido van Rossum (python.org/~guido)
>> _______________________________________________
>> Python-Dev mailing list
>> Python-Dev at python.org
>> https://mail.python.org/mailman/listinfo/python-dev
>>
> Unsubscribe:
>> https://mail.python.org/mailman/options/python-dev/brett%40python.org
>>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/yselivanov.ml%40gmail.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171125/a3c4221f/attachment.html>


More information about the Python-Dev mailing list