Hi,
Python doesn't scope variables from a for loop, which I don't think I've ever intentionally used as a language feature, and has only been a source of bugs for me.
for x in range(5):
print(x)
print(x) # conspicuous usage
I think this would be the same for scopes like context managers; using the file pointer after exiting the open context manager.
I dunno if this is something that would maybe be considered for bugbear to identify.
I was thinking that when it's intentional usage could maybe be identified with something like:
x = None
for x in range(5):
print(x)
print(x)
# OR
for x in range(5):
print(x)
last_x = x #noqa
Thanks for considering this.
Hi,
Python doesn't scope variables from a for loop, which I don't think I've ever intentionally used as a language feature, and has only been a source of bugs for me.
I think this would be the same for scopes like context managers; using the file pointer after exiting the
opencontext manager.I dunno if this is something that would maybe be considered for bugbear to identify.
I was thinking that when it's intentional usage could maybe be identified with something like:
Thanks for considering this.