[issue44332] For Loop temporary variable scope should be local to For loop

2021-06-06 Thread Mark Dickinson
Change by Mark Dickinson : -- status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://

[issue44332] For Loop temporary variable scope should be local to For loop

2021-06-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: By the way, loop variables are not considered to be "temporary" in Python. They are no more temporary than any other local variable -- they *are* local variables with exactly the same scope and lifetime as all other local variables. --

[issue44332] For Loop temporary variable scope should be local to For loop

2021-06-06 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is not a bug, it is intentional design and has been since Python 1. You are incorrect about x consuming memory "always". If the value bound to x is in use elsewhere, deleting x will save no memory. If the value is not in use elsewhere, it will be garba

[issue44332] For Loop temporary variable scope should be local to For loop

2021-06-06 Thread Debasis Satapathy
New submission from Debasis Satapathy : numbers = [1, 2, 3, 4, 5, 6, 7, 8] for x in numbers: print(x) print(x) In the above code, print(x) statement should give error. Because x scope should be local to for loop only. 99% cases, developers will not use the temporary variable x outside of t