else clauses in while and for loops

Ralph Corderoy ralph at inputplus.demon.co.uk
Sun Apr 2 07:24:37 EDT 2000


> > > > Please give some examples showing the real need for else
> > > > clauses in this context.
> >
> > I don't think that is a real need.  Wouldn't it normally be written
> > to return ASAP rather than jump through hoops.
>
> True.  But, using "else" avoids having to deal with a local variable
> to find out how it left the loop.

I realise that, but I didn't use a local variable either;  one wasn't
needed because it was the example I was replying to was poor.  The
original poster asked for `some examples showing the real need for else
clauses in this context'.  I was trying to point out that the example
given didn't show a real need.


Ralph.




More information about the Python-list mailing list