Conditional Expressions don't solve the problem

Guido van Rossum guido at python.org
Wed Oct 17 02:52:36 EDT 2001


Dale Strickland-Clark <dale at riverhall.NOTHANKS.co.uk> writes:

[for...else example snipped]
> 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.

It comes from the analogy between

    while <expr>:
        <code>
    else:
        <code>

and

    if <expr>:
        <code>
    else:
        <code>

In both cases, when <expr> is false, a jump to the else: label is
taken.

>From this it also follows that the else part of a loop is skipped when
a break is taken -- hence finally would be wrong.

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

What do you mean?

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list