[Python-ideas] for/else syntax

Yuvgoog Greenle ubershmekel at gmail.com
Fri Oct 2 16:00:36 CEST 2009


On Fri, Oct 2, 2009 at 2:14 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:

>
>
> Encouraging people to refer to the idiom as "break/else" and including a
> SyntaxWarning for dubious usage of loop else clauses (i.e. those without
> an associated break statement) are probably two fairly low cost
> educational steps that could be taken though.
>
>
A SyntaxError would be more fitting for py4k but it's still not gonna make
the for..else code readable.

Asking people to call this construct a "break/else" is confusing because:
1. "break/else" insinuates the "else" block is for when a break statement
_did_ occur.
2. the "else" is located immediately after the "for" block. Calling this
anything but "for..else" is going to cause a tongue-twisting, mind boggling
Stroop effect. IMHO the only way to avoid this is to rename/modify "else" to
somehow convey it's relation to the break statement.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20091002/5a452547/attachment.html>


More information about the Python-ideas mailing list