
spir wrote:
But sure, again, the ambiguity of "in" seems to be an obstacle for python to adopt the obvious way.
Again, the human parsing problem is actually more important than the computer parser limitations. The Python for loop conditions developers to think "for x in seq <do something>" (where <do something> is written out as a colon, a newline, some indentation and additional code). The genexp/comprehension syntax, brings the "<do something>" to the front as "<produce this value> for x in seq". Mapping is just the degenerate case where the value provided *is* x, but making that implicit doesn't make *anything* more obvious in the way that omitting the filter clause obviously means "unfiltered". Instead, omitting the clause makes it look like the start of a regular for loop (assuming the for keyword is kept), so a developer is going to go looking for the "do something" part of the loop and won't find it. You're suggesting a change that doesn't make anything clearer (and, in fact, will almost certainly make reading code harder since developers will have another idiom to learn), provides a second way of writing "x for x", and doesn't really even save the person writing the code any time. What's the concrete benefit that justifies even the time we've spent discussing the matter in this thread, let alone anyone actually taking the time to code the necessary grammar changes? Cheers, Nick. P.S. We haven't even mentioned the fact that this runs afoul of the language change moratorium yet :) -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia ---------------------------------------------------------------