[Python-ideas] SyntaxWarning for for/while/else without break or return?

Stephen J. Turnbull stephen at xemacs.org
Thu Oct 8 18:33:12 CEST 2009

geremy condra writes:

 > I grant you that compilers *shouldn't* be smarter than programmers,
 > but I highly doubt that any program including an extraneous else
 > clause is "working according to specifications", and that's the point
 > of this proposal.

Actually, I can imagine someone developing a style where a redundant
else was used to indicate "this is part of/cleanup of the for loop,
and should go with it in any refactoring".

Say, in a program that speaks SMTP:

    for line in line_factory:
        smtp_send(line + "\n")

More information about the Python-ideas mailing list