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

Guido van Rossum guido at python.org
Mon Jul 9 15:05:20 EDT 2018


I think this is worth a try.

On Mon, Jul 9, 2018 at 12:04 PM Chris Barker - NOAA Federal <
chris.barker at noaa.gov> wrote:

> TL;DR-
>
> +1 on advocating the term “generator comprehension” as a synonym for
> “generator expression” in future documentation and instructional
> materials.
>
> The long version:
>
> If we were starting from scratch, maybe it would makes sense to use “
> builder” or something else, rather than comprehension. But we’re  not
> starting from scratch.
>
> And “list comprehension” has become a pretty universal (or at least
> common) term in the python world. So we really can’t expect to re-name
> that.
>
> And despite the term having its roots in an esoteric corner of
> mathematics, I’ve never seen anyone confused by it — it’s just a new
> word for a new thing to most folks.
>
> Which is actually why “generator expression” is a bit confusing — it
> seems to have more in common with comprehensions than with generators
>
> (As in: the things functions with a yield in them produce)
>
> In fact, the term “generator” is a bit confusing itself — due to it
> being a common English word, it seems to refer to the generic idea of
> “a thing that generates values on the fly”, which, of course it can be
> in Python. But it actually is a specific type. And you can make a
> “thing that generates values in the fly” with a regular class that
> follows the iterator protocol.
>
> So re-using the word in “generator expression” just adds a bit to the
> confusion. (Even though it’s technically correct, it does “make” an
> actual generator object, doesn’t it? (On a phone, so I can’t check)
> but that’s kind of an implementation detail.
>
> Also: if you google: “python list comprehension” you get a LOT of hits
> to tutorials, etc.
>
> So it is WAY too late to change that name.
>
> When you google “python generator expression” the top hit is the
> python docs, and the next few are about comparing generator
> expressions and list comprehensions.
>
> So I think we could start a new naming scheme for those.
>
>  ‘cause then we’d get lost of questions about the difference between
> generator expressions and generator comprehensions ;-)
>
>
> -CHB
>


-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180709/5982d8ee/attachment-0001.html>


More information about the Python-Dev mailing list