On Tue, Jul 21, 2020 at 10:07:47PM +0100, Barry wrote:
> 1. Because that not what else mean today. Its elif never looped.
py> for x in [1,2]:
... print("inside loop")
... else:
... print("elif never looped")
...
inside loop
inside loop
elif never looped
This is why I have long-argued that the keyword here should be *then*
not else. The semantics are that the loop executes, *then* the following
"else" block executes, unless we have transferred control elsewhere by
jumping out of the loop with return, raise, or break.
Mistaking the semantics for "if never looped" is a very common mistake.
Welcome to the club :-)
--
Steven
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/J57G33FOMK77FJX275JUT4U2A54N43Y5/
Code of Conduct: http://python.org/psf/codeofconduct/