[Python-ideas] Assignments in list/generator expressions

Eugene Toder eltoder at gmail.com
Sun Apr 10 20:31:38 CEST 2011


> We'll have to disagree then.  I think 'for name in [expr]' is a whole
> lot more readable than 'with name = expr'.  Indeed, my recent
> experience in code reading had shown, I thought, that a good number of
> people are using the with statement

It's well known that minor syntax details cause a lot of disagreement
(http://www.haskell.org/haskellwiki/Wadlers_Law), so that's not very
surprising. However, are you sure you're not confusing python's with
statement and 'with' word in my email, which is simply a placeholder
for appropriate keyword to mirror Haskell's 'let'? Or was this just an
occasion to complain about with statement abuse, unrelated to list
comprehension discussion?

If I was not clear: I used 'with' keyword for demonstration purposes
only, to show what the syntax *might* look like. I do not suggest to
reuse 'with' (even though python has a history keywords reuse, e.g.
'else'), it's just a placeholder.

> While naming the iteration variables is a fundamental part of writing
> comprehensions, naming other subexpressions is not, so it doesn't make
> sense to provide comprehension specific syntax for it.

Well, apparently designers of Haskell, Scala, F# and Clojure decided
that it does make sense to provide a comprehension specific syntax for
naming subexpressions in comprehensions.

Eugene



More information about the Python-ideas mailing list