[Python-Dev] accumulator display syntax
python at rcn.com
Tue Oct 21 17:59:56 EDT 2003
> 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.
So, I drop my request for bracketed yields and throw my tiny weight
behind this idea for an iterator expression.
> We can quibble about whether double parentheses are needed
I vote for not requiring the outer parentheses unless there is an
adjacent comma. That would unnecessarily complicate the simple,
Otherwise, I would anticipate frequent questions to the help list
or tutor list on why something coded like your example doesn't work.
Also, the double paren form just looks funny, like there is something
wrong with it but you can't tell what.
Based on the extensive comp.lang.python discussions when I first
floated a PEP on the subject, I conclude that the user community
will very much accept the new form and that there is no reason
to not include it in Py2.4.
If there is any doubt on that score, I would be happy to update
the PEP to match the current proposal for iterator expressions
and solicit more community feedback.
More information about the Python-Dev