On Thu, 23 Jul 2020 at 16:25, Stephen J. Turnbull <
turnbull.stephen...@u.tsukuba.ac.jp> wrote:

> Mathew Elman writes:
>
>  > Frankly, saying that a part of a language that is frequently
>  > misunderstood, is *never* allowed to be improved is disappointing
>  > when the suggestion that it can be (somehow) has been so well
>  > received by everyone else.
>
> The highly improbable is frequently well-received.
>
> What can surely be improved is the documentation, specifically the
> Tutorial.  Something like
>
>     The else clause of a loop statement has frequently been
>     misunderstood.  In a for or while loop *statement*, on each
>     iteration, the condition is tested and exactly one of the
>     following occurs:
>
>     1.  If truthy, the loop *suite* runs to completion and the test is
>         repeated for the next iteration,
>     2.  OR the loop *suite* runs and there is a nonlocal exit such as
>         return or break or raise, which exits the statement as well.
>     3.  OTHERWISE the condition is false, and the else suite, if any,
>         runs, then the statement is exited.
>
> The emphasis is for contrast in this discussion.  The Language
> Reference already says precisely this, although much more concisely.
>
> I don't expect supporters of "elif not break" etc to think this is
> sufficient, and supporters of the Else Ban similarly.  Please consider
> if this is helps clarify the Tutorial, and if it doesn't get booed
> into oblivion, I'll work up a patch (I think that the section on
> control flow would benefit from some reorganization as well, "just
> stick it in somewhere" is not what I have in mind :-).
>

Credit where credit is due, I think this is definitely an improvement. It
does make it require slightly less meticulous reading to understand `else`.
However, I still think that there is value in improving the `for...else`
and `while...else` intuitiveness, if it can be done at an acceptable cost.
(As is the case with any change)

IMO the solution is not to change `else` but to add an additional with the
opposite meaning that makes the use of `else` with `for` and `while` more
intuitive, such as adding `elif`, which feels natural, and a special
boolean, which perhaps doesn't. Or adding `except` for catching raised
Exceptions  rather than breaks, which makes `else` clearly behave how it
does for `try`. Or another solution that achieves the additional clarity
*without* removing/changing else itself.



> Steve
>

-- 


Notice: 
This email is confidential and may contain copyright material of 
members of the Ocado Group. Opinions and views expressed in this message 
may not necessarily reflect the opinions and views of the members of the 
Ocado Group.

If you are not the intended recipient, please notify us 
immediately and delete all copies of this message. Please note that it is 
your responsibility to scan this message for viruses.

References to the 
"Ocado Group" are to Ocado Group plc (registered in England and Wales with 
number 7098618) and its subsidiary undertakings (as that expression is 
defined in the Companies Act 2006) from time to time. The registered office 
of Ocado Group plc is Buildings One & Two, Trident Place, Mosquito Way, 
Hatfield, Hertfordshire, AL10 9UL.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/TN7G7VPAOUKW7FPCYYU5CZIKNSIQPMPX/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to