
On Friday 17 October 2003 10:38 pm, Phillip J. Eby wrote: ...
Ironically, with iterator comprehension in place, a list comprehension would now look like a list containing an iterator, which I agree might be confusing. Too bad we didn't do iterator comps first, or list(itercomp) would be the idiomatic way to make a listcomp.
Yes. But don't mind me, I'm still sad that we have range and xrange when iter(a:b) and list(a:b:c) would be SUCH good replacements for them if slicing-notation was accepted elsewhere than in indexing, or iter[a:b] and list[a:b:c] if some people didn't so strenuously object to certain perfectly harmless uses of indexing...;-)
That's really the only confusing bit I see about itercomps... that you have to be careful where you put your parentheses, in order to make your intentions clear in some contexts. However, that's true for many kinds of expressions even now.
Yes. But since iterator comprehensions are being designed from scratch I think we can MANDATE parentheses around them, and a 'yield' right after the open parenthesis for good measure, to ensure they are not ambiguous to human readers as well as to parsers. Alex