> [Guido, on {for,while}/else] > ... > > The question remains whether Python would be easier to learn without > > them. And if so, the question would remain whether that's offset by > > their utility for experienced developers. All hard to assess > > impartially!
[Tim saves the day] > That's what I'm here for. I like loop "else" clauses, but have to > admit that (a) I rarely use them; (b) most of the time I use them, my > control flow is on the way to becoming so convoluted that I'm going to > rewrite the whole function soon anyway; and, (c) I've often misread > code that uses them, mentally attaching the "else" to a nearby "if" > instead. > > I also suspect that if they weren't in the language already, a PEP to > introduce them would fail, because > > still_looking = True > some loop: > if found it: > still_looking = False > break > if still_looking: > # what would have been in the "else" clause > > is clear and easy to write without it. OTOH I don't particularly like code that requires flag variables; 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. How would a PEP to *remove* this feature fare today? Unhelpfully, -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com