On Fri, May 20, 2016 at 3:09 AM, Erik <pyt...@lucidity.plus.com> wrote: > On 20/05/16 00:51, Gregory Ewing wrote: >> >> It's not so bad with "else" because you need to look back >> to find out what condition the "else" refers to anyway. > > > With my tongue only slightly in my cheek, if it was desirable to > "fix"/clarify this syntax then I would suggest adding some optional > (existing) trailing keywords to 'else' in this context that spells it out: > > for item in seq: > if foo(item): > break > else if not break: > nomatch()
With tongue firmly cheeked, you can always use the special `:#` operator: for item in seq: if foo(item): break else:# if no break: nomatch() This has the benefit that you can use whatever syntax you like after the `:#`, and use it in any version of Python you want. -- Zach -- https://mail.python.org/mailman/listinfo/python-list