
Oct. 21, 2003
10:07 p.m.
On Tue, 2003-10-21 at 17:59, Raymond Hettinger wrote:
[Guido]
I expect that most iterator comprehensions (we need a better term!) are not stored in a variable but passed as an argument to something that takes an iterable, e.g.
sum(len(line) for line in file if line.strip())
That is somewhat beautiful.
Indeed, as is the term "generator expression" and the relegation to syntactic sugar of list comprehensions.
We can quibble about whether double parentheses are needed
I vote for not requiring the outer parentheses unless there is an adjacent comma.
I like that too. It mirrors other situations where the parentheses aren't needed except to disambiguate syntax. In the above example, there's no ambiguity. -Barry