[Python-Dev] Naming comprehension syntax [was Re: Informal educator feedback on PEP 572 ...]

Ivan Pozdeev vano at mail.mipt.ru
Fri Jul 6 19:58:23 EDT 2018


On 07.07.2018 2:31, Guido van Rossum wrote:
> On Fri, Jul 6, 2018 at 4:19 PM Terry Reedy <tjreedy at udel.edu 
> <mailto:tjreedy at udel.edu>> wrote:
>
>     Since Guido, the first respondent, did not immediately shoot the idea
>     down, I intend to flesh it out and make it more concrete.
>
>
> Maybe I should have shot it down. The term is entrenched in multiple 
> languages by now (e.g. 
> https://en.wikipedia.org/wiki/List_comprehension). Regarding "list 
> builder" one could argue that it would just add more confusion, since 
> there's already an unrelated Builder Pattern 
> (https://en.wikipedia.org/wiki/Builder_pattern) commonly used in Java. 
> (Though I worry about the presence of a Python example in that 
> Wikipedia page. :-)

According to https://en.wikipedia.org/wiki/List_comprehension#History, 
the term's known from at least 1977 and comes from such influential 
languages as NPL, Miranda and Haskell. So it's not you to blame for it :-)

>
> Also, "generator builder" is not much more expressive than "generator 
> expression",

"generator builder" is simply incorrect. The GE doesn't "build" 
generators, it's a generator itself. It's a generator _and_ an 
expression. What could be a more obvious name?
This suggestion looks like coming from someone who hasn't quite grasped 
generators yet.

> and the key observation that led to this idea was that it's such a 
> mouthful to say "comprehensions and generator expressions".

Since "X comprehensions" are advertised as and intended to be 
functionally equivalent to `X(generator expression)', I use just 
"generator expressions" to refer to all.
That's accurate because the common part with the distinctive syntax -- 
which is the thing referred to when addressing them all -- effectively 
_is_ a generator expression (the syntax differences in the leading term 
are insignificant), what wraps it is of no concern.

So, no new terms are necessary, but someone who cares may add a note to 
the docs to this effect.

> Maybe it's not too late to start calling the latter "generator 
> comprehensions" so that maybe by the year 2025 we can say 
> "comprehensions" and everyone will understand we mean all four types?
>
> FWIW more people should start using "list display" etc. for things 
> like [a, b, c].
> -- 
> --Guido van Rossum (python.org/~guido <http://python.org/%7Eguido>)
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/vano%40mail.mipt.ru

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180707/1938b912/attachment.html>


More information about the Python-Dev mailing list