On Sat, Apr 2, 2011 at 5:45 PM, Alan Gauld <[email protected]>wrote:

>
> There are other ways but those should cover most eventualities.


I find that my preferred way when the loops are nested is to move the loops
into a function and then return:

def do_something(collection, collection2):
    for x in  collection:
        for y in collection 2:
             if someCase(x,y):
                 return

It seems (at least to me) a little nicer than sentinel values or throwing an
exception.

Just my $.02
-Wayne
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to