[Python-Dev] if-syntax for regular for-loops

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Oct 4 01:34:10 CEST 2008

Vitor Bosshard wrote:
>>On Fri, Oct 3, 2008 at 6:10 AM, Andreas Nilsson wrote:
>>Essentially, all that saves is a newline
>>or two, which, as I think has been generally accepted, tends to hurt
> The exact same argument could be used for list comprehensions themselves.

No, an LC saves more than newlines -- it saves the code
to set up and append to a list. This is a substantial
improvement when this code would otherwise swamp the
essentials of what's being done.

This doesn't apply to a plain for-loop that's not
building a list.


More information about the Python-Dev mailing list