[Python-Dev] Chaining try statements: eltry?

Tim Peters tim.peters at gmail.com
Thu Jul 7 21:17:39 CEST 2005


[Guido]
> OTOH I don't particularly like code that requires flag variables;

Me neither; that's indeed why this one isn't a slam dunk.

> they often make me squirm because the same condition (flag) is
> tested multiple times where it could be tested just once if more
> sophisticated flow control (e.g. an else clause :) was available.

What burns me (far) more often in practice is "simulating" a
multi-level `break` or `continue`.  Then multiple flag variables get
introduced, set, and tested multiple times at multiple "logical indent
levels" too.  That can also be viewed as stemming from a lack of more
sophisticated flow control.  One-loop found-it-or-didn't kinds of flag
variables have spatial locality that makes them (IME) quite easy to
live with, in comparison.

> How would a PEP to *remove* this feature fare today?

Easy:  it would be rejected, but with a note that it should be
reconsidered for Python 3000.

> Unhelpfully,

your-opposite-in-oh-so-many-ways<wink>-ly y'rs  - tim


More information about the Python-Dev mailing list