for <var> in <sequence> if <condition>

Dave Brueck dbrueck at edgix.com
Thu Oct 5 13:30:30 EDT 2000


    Dave> for line in lines if line.strip.startswith('y'):
    Dave>   doStuff(line)

>What's wrong with
>
>    for line in lines:
>        if line.strip().startswith('y'):
>           doStuff(line)

Nothing at all. But then again, there's nothing wrong with 'x = x + 1'
instead of 'x += 1', either. :)

-Dave





More information about the Python-list mailing list