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

Felipe Almeida Lessa felipe.lessa at
Sun May 21 20:46:21 CEST 2006

Em Dom, 2006-05-21 às 17:11 +0200, Heiko Wundram escreveu:
>       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> 

Today you can archive the same effect (but not necessarily with the same
performance) with:

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

But that's ugly...


More information about the Python-list mailing list