In other languages - loops form closed scopes (so that variables declared inside the loop don't exist outside).
In Python for loops don't for closed scopes - variables are considered to all be at the function level and will only dissappear at the end of the function.
Remember that for simple things like this - Python is heavily used across industry millions of times per day, so trivial things that look different are likely to be by design and are unlikely to be bugs.
------ Original Message ------
From: "Ali Arslan" <583831@csinow.edu>
To: "docs@python.org" <docs@python.org>
Cc: "Michael Dotolo" <mdotolo@csinow.com>
Sent: Sunday, 6 Mar, 22 At 17:00
Subject: [docs] potential bug in python 3
Hi we just noticed there is a potential bug in for loop
variable assignment in for loop. variable must unset after the block end at least in other programming language they dobut in python 3 last assignment still exist sorry for my bad English but I can tell you with an example
for i in range(3):print(i)
out put is012but if you call i againprint(i)
output2
I don't know it is by purpose for some reason but I haven't seen it in any sourceso most of the programmers don't handle this situation . this situation can cause over ram usage and it might effect program's efficacy and optimization in large scale programs such as games or data processing if programmers don't handle this situation .
ThanksAli ARSLAN
_______________________________________________
docs mailing list -- docs@python.org
To unsubscribe send an email to docs-leave@python.org
https://mail.python.org/mailman3/lists/docs.python.org/
Member address: anthony.flury@btinternet.com