Movatterモバイル変換


[0]ホーム

URL:


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

Paul Moorep.f.moore at gmail.com
Wed Nov 22 11:43:28 EST 2017


On 22 November 2017 at 16:30, Ivan Levkivskyi <levkivskyi at gmail.com> wrote:> On 22 November 2017 at 17:24, Antoine Pitrou <solipsis at pitrou.net> wrote:>> Given a comprehension (e.g. list comprehension) is expected to work>> nominally as `constructor(generator expression)`>> As Yury just explained, these two are not equivalent if there is an `await`> in the comprehension/generator expression.As Antoine said, people *expect* them to work the same. If they don't,then that's a subtle change that came in as a result of the new asyncfunctionality. It's a shame that this wasn't made clearer at the time- one of the major issues I see with async is that it works "nearly,but not quite" the way people expect, and we need to do more to helppeople integrate async into their intuition. Just reiterating "that'snot right" isn't much help - we need to educate people in betterintuitions if the traditional ones are no longer accurate.At the moment, I know I tend to treat Python semantics as I alwaysdid, but with an implicit proviso, "unless async is involved, when Ican't assume any of my intuitions apply". That's *not* a goodsituation to be in.Paul


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp