osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Generator Comprehensions


Based on feedback from people annoyed at having to write "comprehensions 
and generator expressions" to refer to what ought to be a single concept, 
Guido has given the thumbs up for a documentation change to start 
referring to "generator comprehensions".


https://mail.python.org/pipermail/python-dev/2018-July/154554.html


This now combines four related syntax under one umbrella term:

Comprehension:

  - list comprehension [expr for x in values]

  - set comprehension {expr for x in values}

  - dict comprehension {key:value for x in values}

  - generator comprehension (expr for x in values) 
    a.k.a. generator expression



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson