Hello,
On Wed, 22 Jul 2020 09:45:31 +1000
Steven D'Aprano <[email protected]> wrote:
> 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,
But no, loop executes, *or else* the following "else" block
executes ;-). That's the logic of founding fathers. After one grasped
that logic, one comes to appreciate a weird beauty of it. The verdict
remains the same though: "Do Not Use".
> 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
[]
--
Best regards,
Paul mailto:[email protected]
_______________________________________________
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/ZQLNLIHMYY6THKHWVDAOPI6M5YV5OPCJ/
Code of Conduct: http://python.org/psf/codeofconduct/