New submission from Debasis Satapathy <deb_...@yahoo.co.in>:
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 the for loop. So x will keep on consuming memory always. So it is a bad usage of memory. Ideally x memory should be free once for loop execution is completed. ---------- components: Library (Lib) messages: 395246 nosy: deb_ctc priority: normal severity: normal status: open title: For Loop temporary variable scope should be local to For loop type: behavior versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44332> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com