On 9/17/13 2:56 PM, Skip Montanaro wrote:
I have a function which uses for ... else, with an early return.
Here's a cut down version of it:
"""..."""
def func(c, dt, ct):
for cl, op in zip(c.events[0::2], c.events[1::2]):
delta = cl.event_datetime - dt
if delta > ct:
return dt + ct
else:
dt = op.event_datetime
ct -= delta
else:
return dt
Pylint (1.0.0) complains:
early_exit.py:11: [W0120(useless-else-on-loop), func] Else clause on
loop without a break statement
But this "else" is useless, isn't it? Just put the "return dt"
statement after the for statement, no else needed.
--Ned.
_______________________________________________
code-quality mailing list
code-quality@python.org
https://mail.python.org/mailman/listinfo/code-quality