George Sakkis wrote: > On Sep 29, 10:34 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: >> [EMAIL PROTECTED] wrote: >> >> > On 29 sep, 12:04, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >> > >> >> for i in generator_a: # the first "for" cycle >> >> for j in generator_b: >> >> if something_happen: >> >> # do something here ..., I want the outer cycle to break >> >> break >> > >> > Do you like this? >> > >> > generator_ab = ((x, y) for x in generator_a for y in generator_b) >> > for i, j in generator_ab: >> > if condition: >> > # do something >> > break >> > >> In this case, the tuple generator_ab must be generated first. > > It's not a tuple, it is a generator expression that can generate > tuples *lazily*. > >> Sometime it maybe a waste to generate all possible combinations of i,j first. > > It doesn't; read about generator expressions at > http://www.python.org/dev/peps/pep-0289/ > > George > Thanks, I didn't realize that.
However, I still think labeled break and continue is a valuable feature, which is easier to understand and to use. -- http://mail.python.org/mailman/listinfo/python-list