[EMAIL PROTECTED] a écrit :
> A very old thread:
> http://groups.google.com/group/comp.lang.python/browse_frm/thread/2c5022e2b7f05525/1542d2041257c47e?lnk=gst&q=for+else&rnum=9#1542d2041257c47e
> 
> discusses the optional "else:" clause of the for statement.
> 
> I'm wondering if anyone has ever found a practical use for the else
> branch?
> 

I use it regularly in contructs like:

     for value in someList:
         if someCondition(value):
             print "a matching item was found"
             break
     else:
         print "no matching item"
         return False

     # ... continue with value

-- 
Amaury
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to