On Wed, Jul 29, 2020 at 07:01 Mathew Elman <mathew.elman@ocado.com> wrote:


On Wed, 29 Jul 2020 at 14:42, Guido van Rossum <guido@python.org> wrote:
On Wed, Jul 29, 2020 at 02:51 Mathew Elman <mathew.elman@ocado.com> wrote:

.
If it *is* useful, it occurs to me that (1) this looks a lot like the
try ... except ... pattern, and (2) breaks are generally perceived as
exceptional exits from a loop.  Instead of "if break [LABEL]", "except
[LABEL]" might work, although the semantic difference between labels
and exceptions might get a ton of pushback.
...
Steve
 
In the related thread I suggested using `except`, but it was largely ignored.


*If* you want tou propose clearer syntax for this, please extend the loop syntax, not the ‘if’ syntax. So, ‘case ... zero’ makes more sense than ‘if [not] break’.
 
—Guido
 
So I understand, does this mean that any extended syntax for this should be totally new and not draw on existing constructs such as `try-except` or `if-else`?
Or just that the additional clarity should come from  extending the loop rather than the implicit `if`?

Actually, given that ‘else:’ already confuses people I very much doubt that any other new construct will be acceptable. It is totally five not to “solve” this problem at all — all use cases can be done by adding flag variables explicitly manipulated by the user’s code.
I understand that the "problem" with `else` is aesthetic, though one could debate the importance of such a problem.

What I mean to ask is, for example,  would having `for-except-else` (analogous to `try-except-else`) be an acceptable extension of "the loop syntax, not the ‘if’ syntax"?

I honestly and strongly believe that we should do nothing here. Python thrives because it is relatively simple. Adding new syntax to deal with looping special cases makes it less simple, and encourages a bad coding style (nested loops, multiple breaks...).




Mathew


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-leave@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/TVTCXQN5KDMQUCFQ7AJES2RISPFD6OTL/
Code of Conduct: http://python.org/psf/codeofconduct/
--
--Guido (mobile)

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-leave@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/YTC6Z4DHUOXSKS7L6MM4HQ4WSZAGVSET/
Code of Conduct: http://python.org/psf/codeofconduct/
--
--Guido (mobile)