Steven D'Aprano <ste...@remove.this.cybersource.com.au> writes:
> But the consequence of that simplicity and speed is that they're not as 
> general as a for-loop. This was a design decision. But change the design 
> and you could have something like this:
> 
> [expr for name in seq until cond]
> 
> which breaks when cond becomes true.

from itertools import takewhile
xs = [expr(name) for name in takewhile(lambda s: not cond(s), seq)]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to