a break for comprehensions

Greg Ewing greg at cosc.canterbury.ac.nz
Mon Jul 30 01:29:01 EDT 2001


Kevin Lacker wrote:
> 
> answer = [process(x) for x in my_list while is_good(x)]

Looks quite nice. But what should

  answer = [process(x,y) for x in a for y in b while f(x,y)]

do? Should the break terminate the whole comprehension,
or just the enclosing for-clause?

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list