Warn about defining a loop variable that steps on an outer variable.
Bug #1408774 reported by
wsanchez
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pyflakes |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
This code may be worth a warning:
foo = 1
for foo in (2,3,4):
pass
It's easy to accidentally step on a variable in a for loop, where usually one only uses the loop variable within the loop.
Changed in pyflakes: | |
status: | Incomplete → Triaged |
importance: | Undecided → Wishlist |
To post a comment you must log in.
Indeed. The problem is I haven't been able to think of a way to do that which doesn't also catch legitimate use cases.
This was discussed recently on the code-quality mailing list. Archive here: https:/ /mail.python. org/pipermail/ code-quality/ 2014-December/ 000450. html
Can you think of some logic that would catch the problem in your example, but not also apply to at least some of the use cases enumerated in that thread, thus generating false positives?