
On 18 September 2013 02:39, Skip Montanaro <skip@pobox.com> wrote:
Ned,
I still think you're missing the point of my original post. A return is as good as a break when considering early exit from a loop. The pylint code only checks for the presence of a break statement, but the test cases clearly show a case with a return statement. The test functions even include docstrings which state that.
It's not considering the exit from the loop it's considering the entry to the else clause. A break would continue past the body of the loop without entering the else clause (so the else would have a meaning - only enter this code if we haven't hit break). Without a break the else clause will always be entered if the loop terminates normally, so the else is useless. Just putting the return immediately after the loop is functionally identical. That you have some early returns inside the body of the loop is irrelevant - the "else" is still unnecessary / pointless. Michael
That's all I'm trying to point out. That I discovered the problem in a piece of code which could be rewritten to avoid the warning is quite beside the point.
Skip _______________________________________________ code-quality mailing list code-quality@python.org https://mail.python.org/mailman/listinfo/code-quality
-- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html