[Python-Dev] Tricky way of of creating a generator via a comprehension expression
Ivan Levkivskyi
levkivskyi at gmail.com
Wed Nov 22 11:03:10 EST 2017
On 22 November 2017 at 16:53, Paul Moore <p.f.moore at gmail.com> wrote:
> 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.
>
> Paul
>
Looking at
https://docs.python.org/3/reference/expressions.html?highlight=generator%20expression#generator-expressions
it is indeed not super clear what it _should_ mean.
I agree this requires documentation updates.
--
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171122/5b4e71c4/attachment.html>
More information about the Python-Dev
mailing list