Proposed new syntax

Gregory Ewing greg.ewing at canterbury.ac.nz
Sun Aug 13 18:55:40 EDT 2017


Steve D'Aprano wrote:

> Python's comprehensions are inspired by Haskell's, but we made different choices
> than they did: we make the fact that a comprehension is a loop over values
> explicit, rather than implicit, and we use words instead of cryptic symbols.

The presence of the word "for" in the comprehension syntax doesn't
by itself imply that the values are generated by a sequential loop.

Comprehensions in Python are intended to be read declaratively.
The definition in terms of an expansion into nested loops may
imply that if you take it absolutely literally, but when I
devised that expansion I only meant it as a way of defining
the result -- I didn't intend the equivalence to extend to side
effects.

However, Steve's other points remain -- Python's overall style
is one of explicitness and clarity. The proposed extensions
don't fit into that style.

-- 
Greg



More information about the Python-list mailing list