Cliff Wells wrote:
On Mon, 2008-09-15 at 14:11 +1200, Greg Ewing wrote:
Cliff Wells wrote:
'-'.join ( for J in I: YIELD ( for j in J: YIELD j ) )
join() takes care of flattening the final yielded iterator.
But the final iterator is yielding other iterators, not strings, unless I misunderstand the semantics you have in mind.
Get into nested listcomps and the readability (or more to the point the comprehensibility) pretty much vaporizes.
That depends on what you mean by "nested listcomps". I agree that nesting one entire listcomp inside another tends to look rather confusing: [f(a) for a in [g(b) for b in y]] But that's not the same thing as having nested *loops* within a single listcomp, which I don't think is particularly bad at all: [f(a, b) for a in x for b in y] or if you prefer, [f(a, b) for a in x for b in y]
Sure, I think listcomps have a place. I still maintain that they are logically redundant if you have if-expressions (not to mention less flexible)
Yes, but they're also logically redundant even if you don't have statement-expression equivalence, so that's not an argument for merging statements and expressions. -- Greg