for what are for/while else clauses

John Roth newsgroups at jhrothjr.com
Fri Nov 14 18:40:03 EST 2003


"JCM" <joshway_without_spam at myway.com> wrote in message
news:bp3ej3$n35$1 at fred.mathworks.com...
> John Roth <newsgroups at jhrothjr.com> wrote:
>
> > "JCM" <joshway_without_spam at myway.com> wrote in message
> > news:bp3bmg$l3$1 at fred.mathworks.com...
> >> John Roth <newsgroups at jhrothjr.com> wrote:
> >> ...
> >> > Yep. It's one of the three termination conditions for a loop.
> >>
> >> What are the three conditions?  I know of two:
> >>
> >>   1 Reaching the end of the iteration
> >>   2 Breaking out
> >      3. Not executing at all.
>
> I see that as an example of #1.

But it isn't. See what your code looks like with an
empty file, for example. Or even worse, see what it
would look like if you have to use a generator where
you can't test for an empty sequence.

John Roth






More information about the Python-list mailing list