[Python-3000] else-clause on for-loops

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Mar 25 05:25:10 CET 2006


Tim Peters wrote:

> The primary use case is "search loops".
> 
> for item in sequence:
>     if desirable(item):
>         break
> else:
>     no desirable item exists

Except that almost all of my search loops are in
functions of their own, and I just use return.
So I don't get to use this use case.

Greg


More information about the Python-3000 mailing list