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

Ivan Levkivskyi levkivskyi at gmail.com
Wed Nov 22 14:37:37 EST 2017


On 22 November 2017 at 20:33, Guido van Rossum <guido at python.org> wrote:

> On Wed, Nov 22, 2017 at 11:12 AM, Ivan Levkivskyi <levkivskyi at gmail.com>
> wrote:
>
>> On 22 November 2017 at 20:05, Guido van Rossum <guido at python.org> wrote:
>>
>>> On Wed, Nov 22, 2017 at 10:54 AM, Jelle Zijlstra <
>>> jelle.zijlstra at gmail.com> wrote
>>>
>>>> 2017-11-22 9:58 GMT-08:00 Guido van Rossum <guido at python.org>:
>>>>
>>> (OTOH, await in the same position must keep working since it's not
>>>> broken and not unintuitive either.)
>>>>
>>>
>>>
>>
>> This is very questionable IMO.
>> So do you think that [await x for y in z] and list(await x for y in z)
>> being not equivalent is intuitive?
>>
>
> I see, that's why this is such a long thread. :-(
>
> But are they different? I can't find an example where they don't give the
> same outcome.
>
>
I think this is a minimal example https://bugs.python.org/issue32113
Also Yury explains there why [await x for y in z ] is different from
list(await x for y in z).
Although I understand why it works this way, TBH it is not very intuitive.

--
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171122/e3bd8f88/attachment-0001.html>


More information about the Python-Dev mailing list