break levels

Benjamin.Altman benjamin.altman at noaa.gov
Mon Apr 16 15:14:02 EDT 2001


Is there a particular reason that Python can't break over multiple
loops?  Example:
    for i in range(0,10):
        for j in range(0,10):
            if some_condition:
                break(2)

which would break out from the inner and outer loop.  This would be
similar to the Bourne shell usage of break.  I suppose you could do a
try and throw an exception instead but it seems that sometimes doing a
break(x) would be convenient.

Ben




More information about the Python-list mailing list