[code-quality] Spurious useless-else-on-loop warning

Ned Batchelder ned at nedbatchelder.com
Wed Sep 18 02:21:51 CEST 2013


On 9/17/13 7:56 PM, Skip Montanaro wrote:
>
>
> > But this "else" is useless, isn't it?  Just put the "return dt" 
> statement after the for statement, no else needed.
>
> In this particular case, yes, but that's not the point of the post. 
> Pylint doesn't check to see what's in the else clause, only whether 
> there is an early exit from the body of the loop.
>
> Skip
>

But is there a sensible use-case for a for loop with an else but no 
break?  I can't think of one.  There's no point changing pylint unless 
you can find a useful piece of code that it complains about.

--Ned.


More information about the code-quality mailing list