
Oct. 17, 2003
9:55 p.m.
[GvR]
Which is why I didn't like the 'sum[x for x in S]' notation much.
[Alex]
Let it rest in peace, then.
Goodbye, weird __getitem__ hack! [GvR]
Let's look for an in-line generator notation instead. I like
sum((yield x for x in S))
[Alex]
So do I, _with_ the mandatory extra parentheses and all, and in fact I think it might be even clearer with the extra colon that Phil had mentioned, i.e.
sum((yield: x for x in S))
+1 [David Eppstein, in a separate note]
Along with that confusion, (x*x for x in S) would look like a tuple comprehension, rather than a bare iterator.
Phil's idea cleans that up pretty well: (yield: x*x for x in S) This is no more tuple-like than any expression surrounded by parens. Raymond Hettinger