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

Paul Moore p.f.moore at gmail.com
Wed Nov 22 10:53:27 EST 2017

On 22 November 2017 at 15:10, Ivan Levkivskyi <levkivskyi at gmail.com> wrote:
> I think there may be a small misunderstanding here. The situation is
> different for comprehensions and generator expressions,
> let me summarize the current state:
> What do you think?

Can you point me to where in the docs it explains the semantic
difference between a generaor expression and a list comprehension?
Ignoring the trivial point that they return different values - think
of [a for a in expr] vs list(a for a in expr) if you like - these
should be semantically the same, I believe?

TBH, the docs aren't super-precise in this area. Before we start
debating the "correct" behaviour of edge cases, I think we need to
agree (and document) the semantics more precisely.


More information about the Python-Dev mailing list