Proposed new syntax
Ben Finney
ben+python at benfinney.id.au
Tue Aug 15 19:30:30 EDT 2017
Gregory Ewing <greg.ewing at canterbury.ac.nz> writes:
> The whole reason to write something as a comprehension is because you
> want to express it declaratively. You're saying "this is the list I
> want, I don't care how you compute it."
That's certainly a strong reason for my choosing comprehension
expressions: when I don't want to write a sequence of statements in a
loop, an expression communicates the intent (“this is one expression
with one output; think of it as one operation”).
> Likewise, the reader should be able to read it as "this is the list
> produced, and you *don't have to care* how it gets computed."
So I find the ‘while’ proposed addition to be counter to that purpose,
and describe it as confounding the ability of the reader to reason about
the expression.
> Introducing procedural elements such as "while" into a comprehension
> messes that up, because suddenly the reader *does* have to care about
> details of how it gets computed.
Thanks for stating it so well, Greg.
--
\ “The good thing about science is that it's true whether or not |
`\ you believe in it.” —Neil deGrasse Tyson, 2011-02-04 |
_o__) |
Ben Finney
More information about the Python-list
mailing list