[Python-ideas] for/else syntax

Nick Coghlan ncoghlan at gmail.com
Fri Oct 2 17:35:19 CEST 2009

Steven D'Aprano wrote:
> On Fri, 2 Oct 2009 09:01:20 pm Nick Coghlan wrote:
>> Yuvgoog Greenle wrote:
>>> 1. Not allowing a for loop that has no "break" to have an "else".
>>> Just like "else" isn't allowed when there isn't an "except" in the
>>> "try". There really is no excuse, justification or sense in a "for"
>>> loop that has no "break" yet has an "else".
>> As Stephen said, that's a very good point. Having the compiler issue
>> a SyntaxWarning when compiling such code is perfectly possible and
>> would make a great deal of sense (and probably prevent many cases of
>> naive misuse).
> I disagree that it makes sense. Why raise a SyntaxWarning for legal 
> code?

Yeah, I was wrong. Definitely in pylint/pychecker territory.


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

More information about the Python-ideas mailing list