[Python-ideas] Nudging beginners towards a more accurate mental model for loop else clauses

Devin Jeanpierre jeanpierreda at gmail.com
Sun Jun 10 05:28:04 CEST 2012

On Sat, Jun 9, 2012 at 11:03 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> There is no evidence that users somehow get the impression that for/else
> behaves like try/finally, and I find it completely implausible that they
> will do so in the future. If I'm wrong, the docs can be revised, but until
> then, in my opinion worrying about this is a documentation case of YAGNI.
> The current documentation for for/else is already specific and correct. The
> real-life problem Nick is trying to solve is that many people think that the
> else clause implies that it behaves like if/else, and Nick is trying to
> nudge users to think of try/else instead. I think that's a worthy goal.
> Worrying about users reading the tutorial and concluding that for/else will
> run when you exit with a return, not so much.

You are confused.

A) I was arguing in favor of the current documentation, written by
    Nick Coghlan. You were arguing in favor of Yuval's thing. You appear
    to have forgotten this, and are now agreeing with me.
B) Obviously there is no empirical evidence for anything, because
    Yuval's thing is unpublished, and the current documentation was added
    two days ago to the dev branch of the docs.

-- Devin

More information about the Python-ideas mailing list