PEP-xxx: Unification of for statement and list-comp syntax

Boris Borcic bborcic at gmail.com
Mon May 22 11:27:11 CEST 2006


Heiko Wundram wrote:
...
>     As I've noticed that I find myself typing the latter quite often
>     in code I write, it would only be sensible to add the corresponding
>     syntax for the for statement:
> 
>       for node in tree if node.haschildren():
>           <do something with node>
> 
>     as syntactic sugar for:
> 
>       for node in tree:
>           if not node.haschildren():
>               continue
>           <do something with node>

Mhhh, your unsugared form remind me of darks hours with primitive BASICS in my 
youth - the kind Dijsktra commented on. Why don't you write

        for node in tree:
            if node.haschildren():
                <do something with node>

?



More information about the Python-list mailing list