On 23 Jul 2020, at 17:04, Rob Cliffe via Python-ideas email@example.com wrote:
On 23/07/2020 16:24, Stephen J. Turnbull wrote:
Steven D'Aprano writes:
On Wed, Jul 22, 2020 at 06:14:39AM +0300, Paul Sokolovsky wrote:
But no, loop executes, *or else* the following "else" block executes ;-).
He means the loop *suite* executes (this includes "getting to" a break statement or other control flow that leaves the loop *statement* entirely), and if it doesn't, the else suite does. This is "why" such nonlocal exits differ from finally in that they don't run the else suite.
I personally think this is a perfectly clear and convincing argument for "else" as the keyword for this statement (once "suite" is added to Paul's phrasing).
This is why programmers should major in English, and do a graduate degree in programming if they really think they need a degree in programming.
The upholders of the status quo regularly provide gallant explanations of why "else" is perfectly natural, even intuitive. The fact is, it isn't. If it were, it wouldn't *need* to be repeatedly explained by gurus to lesser mortals. I can't think of any other area of Python that needs to be defended so regularly and so vociferously, nor that very experienced Python programmers confess they find confusing. Swelp me, someone in this very thread (Barry) misunderstood it. And suggesting that those of us who don't find it clear lack skill in English is just plain insulting.
Yes indeed, my intuition cannot get the for else into my head. And as I proved wonderfully I got it wrong. I never use the for else and in the rare cases I have seen it in code reviews ask that it is replaced because so few people know what it means.
YMMV, but the only way I can grok it when I see it is to mentally translate "else" to "if no break". This is mental effort that would be spared or at least diminished if it were spelt in a more obvious way in the first place.
Best wishes Rob Cliffe  or at least I think he did, I had trouble understanding him. _______________________________________________ Python-ideas mailing list -- firstname.lastname@example.org To unsubscribe send an email to email@example.com https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://firstname.lastname@example.org/message/5GP4EC... Code of Conduct: http://python.org/psf/codeofconduct/