'while' in list comprehension?

Greg Ewing (using news.cis.dfn.de) g2h5dqi002 at sneakemail.com
Wed Nov 12 19:45:50 EST 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
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list