On 22/07/2020 00:29, MRAB wrote:
On 2020-07-22 00:02, Rob Cliffe via Python-ideas wrote:
On 21/07/2020 22:07, Barry wrote:
On 21 Jul 2020, at 18:47, Rob Cliffe via Python-ideas
<python-ideas@python.org> wrote:
On Mon, Jul 20, 2020 at 03:22 Jonathan Fine <jfine2...@gmail.com
<mailto:jfine2...@gmail.com>> wrote:
This is a continuation of my previous post to this thread.
Python's FOR ... ELSE ... , Raymond Hettinger has told us, has
origins in some ideas of Don Knuth.
That’s news to me (both that it’s due to Knuth and that Raymond
said so). I invented it without awareness of prior art, by
reasoning about the similarity between IF and WHILE (FOR followed
from WHILE).
—Guido
See Raymond's video "Transforming Code into Beautiful, Idiomatic
Python" at
https://www.youtube.com/watch?v=OSGv2VnC0go
from 15 min 50 sec to 18 min 57 sec.
On 20/07/2020 15:42, Guido van Rossum wrote:
Also, let me be clear that this feature will never be added to the
language.
With respect, that seems pretty dogmatic, given that for...else is
one of the most confusing features of Python.
What would be so terrible about allowing, at minimum, `if not
break:' as a synonym for 'else:'?
1. Because that not what else mean today. Its elif never looped.
2. Because if after for is confusing. I can get behind elif as after
for it pull work.
I'm sorry, of the above two points I don't understand 1. at all, and
I only half understand 2. Please could you rephrase more clearly for
an idiot like me.:-)
But as to `if` after `for` being confusing, are you seriously saying
that `else` after `for` is *less* confusing?
'if' introduces a statement structure, 'else' doesn't. Having 'if'
sometimes continue a statement structure (a loop) would be more
confusing.
The current rule: 'else' continues the 'if' or loop structure.
The new rule: 'if' continues a preceding loop structure if it's
followed by 'break', else it's the start of an 'if' structure.
Which rule is simpler?
"Simpler" doesn't always equate to "easier to understand".
Which is more *intuitive*, for...else or for...if [not] break?
And if we allowed for...if [not] break... else - now there's an
example of 'else' after 'for' that anyone could grok.
_______________________________________________
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/OCYFEFFPVEQVP7LKY6DMB3KEDRKCJJ7M/
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
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/QU3UPVXQUAYWASTRAFTFVGLGBSI3QZQD/
Code of Conduct: http://python.org/psf/codeofconduct/