<div dir="ltr">you can either manually manage the memory with `del cnt` or let the built in memory management .. manage the memory.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 7, 2013 at 10:54 PM, Jim Mooney <span dir="ltr"><<a href="mailto:cybervigilante@gmail.com" target="_blank">cybervigilante@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This bugs me for some reason. The final variable is saved in a for<br>
loop but not in a list comprehension. It just seems to me they should<br>
both be destroyed to avoid confusion.<br>
<br>
lst = []<br>
for cnt in range(5):<br>
    lst.append(cnt)<br>
cnt<br>
4<br>
<br>
lst = [cnt2 for cnt2 in range(5)]<br>
cnt2<br>
builtins.NameError: name 'cnt2' is not defined<br>
<br>
Is there a form of for loop that would destroy the loop variable? I<br>
could always do del cnt right after the for, but that seems<br>
artificial.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Jim<br>
_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</font></span></blockquote></div><br></div>