for..else local variable might be referenced before assignment

已回答

Look at this piece of code:

for i in range(10):
pass
else:
i # Local variable 'i' might be reference before assignment

Why does PyCharm detect a warning? I can't really think of a scenario where that warning is true.

0

Hi Pablo! I believe this problem is covered by PY-3344 ticket, please vote for it.

0
Avatar
Permanently deleted user

I don't think that's exactly the same problem.

0

Hm, I believe the both problems have the same cause, but let's responsible developer decide - I created a separate ticket PY-27254.

1

请先登录再写评论。