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

Stephen J. Turnbull stephen at xemacs.org
Fri Oct 9 14:25:09 CEST 2009


Steven D'Aprano writes:

 > But that's exactly what it is doing, even if it doesn't use the 
 > word "noise". It's making an editorial judgement that perfectly legal 
 > code that does exactly what it is meant to do is somehow "bad" and 
 > requires a warning.

Tut, tut.  You are confused.  It is true that this perfectly legal
code does exactly what *Guido* meant it to do.  That is not a problem,
as you correctly and oh so tediously insist.  The problem is that it
does *not* do what any number of Pythonistas in the street, as well as
several posters to this very thread, meant it to do.  That is a real
problem, even if you do not suffer from it personally.

 > I shouldn't have to add a spurious "if False: break" to shut the
 > compiler up during those incremental edits.

People who hire otherwise competent Python programmers who think they
know what for...else does -- but are wrong -- shouldn't have to suffer
buggy programs either.  That's what warnings are for.





More information about the Python-ideas mailing list