for what are for/while else clauses

Fredrik Lundh fredrik at pythonware.com
Mon Nov 17 06:46:57 EST 2003


Erik Max Francis wrote:

> > that's not what it means, of course.
> >
> > in every single case, it means "run once, if and only if the
> > controlling condition is false".
>
> Where's the controlling condition in
>
> for x in sequence:
>     ...
> else:
>     ...
>
> ?

you mean you don't know how the for-loop checks if there's
another item in the sequence?

(hint: look for StopIteration in the docs)

</F>








More information about the Python-list mailing list