Conditional Expressions don't solve the problem

Dale Strickland-Clark dale at
Wed Oct 17 00:40:45 CEST 2001

"Andrew Dalke" <dalke at> wrote:

>Wouldn't you prefer (in Python 2.2)
>for term in iter(self.nextTerm, None):
>    for a in argObjects:
>        if a.test(term):
>            break
>    else:
>        raise whatever
>Same number of lines.  No need for ':='.  No ugly flag
>variables.  Very Pythonic.
>                    Andrew
>                    dalke at

That looks OK. Somehow for/else had eluded me but I'm using it now.
Thanks for that.

Having not seen this before, I'm a bit surprised at the choice of the
word 'else' here. It's not an alternative. It's a conclusion. I would
have thought 'then' or 'finally' would have been more appropriate.

A bit late now, I guess.

Is iter just an extra object layer to map the interface. Will it be an

Dale Strickland-Clark
Riverhall Systems Ltd

More information about the Python-list mailing list