redefined-loop-name / W2901#

Message emitted:

Redefining %r from loop (line %s)


Used when a loop variable is overwritten in the loop body.

Problematic code:

for name in names:
    name = name.lower()  # [redefined-loop-name]

Correct code:

for name in names:
    lowercased_name = name.lower()

Configuration file:



This message is emitted by the optional 'redefined-loop-name'

checker which requires the pylint.extensions.redefined_loop_name plugin to be loaded.

Created by the redefined-loop-name checker.