'while' in list comprehension?

Hannu Kankaanp?? hanzspam at yahoo.com.au
Mon Oct 27 05:16:06 EST 2003


"Michael Geary" <Mike at DeleteThis.Geary.com> wrote in message news:<vpii6tiq1rhja3 at corp.supernews.com>...
> Here's an idea that might avoid this bit of confusion:
> 
>     foo = [ i for i in bar until len(i) == 0 ]

Another variation:

foo = [i for i in bar, break if len(i) == 0]

This wouldn't need a new keyword.




More information about the Python-list mailing list