RIIA in Python 2.5 alpha: "with... as"
Terry Reedy
tjreedy at udel.edu
Tue Apr 11 21:17:20 EDT 2006
"Alexander Myodov" <maa_subscriptions at sinn.ru> wrote in message
news:178359972.20060411145606 at sinn.ru...
> Hello,
> for k in a1:
> pass
> print "k: %s" % k
> where "k" lives long after the actual need in it was lost,
There are occasions, especially when one breaks out of the loop, when
keeping k bound *is* useful. If a1 generates big resources that you want
the last one of freed, or if having k still bound just bothers you,
del k
> and even list comprehensions:
> b1 = [l for l in a1]
> print "l: %s" % l
This will go away in 3.0. For now, del l if you wish.
Terry Jan Reedy
More information about the Python-list
mailing list