'while' in list comprehension?

Greg Ewing (using news.cis.dfn.de) g2h5dqi002 at sneakemail.com
Thu Nov 13 01:45:50 CET 2003

Hannu Kankaanp?? wrote:
> Another variation:
> foo = [i for i in bar, break if len(i) == 0]
> This wouldn't need a new keyword.

My thoughts on all this are that if you want to do
something that procedural, it would be better written
out as nested statements. List comprehensions are
meant to be read declaratively.

Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand

More information about the Python-list mailing list