[Python-ideas] for/else syntax

Nick Coghlan ncoghlan at gmail.com
Fri Oct 2 13:06:11 CEST 2009

Yuvgoog Greenle wrote:
> There is no "try/else". OTOH "except/else", as I said before, is a
> beautiful, pythonic, useful and cool construct.

This is also a very good point, but perhaps not quite in the way you
intended (and it relates back to your first point about the compiler not
complaining about redundant else clauses on loops that contain no break

Just as there is no "try/else", but only "except/else", so there is no
"for/else" or "while/else", but only "break/else".

Issuing a SyntaxWarning might be a good way to make that clear.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list