"for/while ... break(by any means) ... else" make sense?
jfong at ms4.hinet.net
jfong at ms4.hinet.net
Wed Jun 29 08:01:12 EDT 2016
Steven D'Aprano at 2016/6/29 UTC+8 10:43:52AM wrote:
> The "else" in for...else has nothing to do with any "if" inside the for
> block.
Yes, the "else" has nothing to do with "break" syntactically in Python language, but semantically in English it cause confusion. When I said "insane", I just want to emphasis this situation.
"else" should appear only when there is a "break" in the "for" block, then "for ...break... else ..." become perfectly alright semantically. Never think of it in "for ...else ..." or the confusion bond to come up:-)
--Jach
More information about the Python-list
mailing list