[Python-Dev] Tricky way of of creating a generator via a comprehension expression (original) (raw)
Paul Moore p.f.moore at gmail.com
Wed Nov 22 11:43:28 EST 2017
- Previous message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Next message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 anawait
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 async functionality. 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 help people integrate async into their intuition. Just reiterating "that's not right" isn't much help - we need to educate people in better intuitions if the traditional ones are no longer accurate.
At the moment, I know I tend to treat Python semantics as I always did, but with an implicit proviso, "unless async is involved, when I can't assume any of my intuitions apply". That's not a good situation to be in.
Paul
- Previous message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Next message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]