del

Chad Netzer cnetzer at mail.arc.nasa.gov
Fri Feb 14 19:31:35 EST 2003


On Fri, 2003-02-14 at 15:49, Daniel Silva wrote:

> Removing items from a container in-place is ok, but I don't see the point 
> of actually undefining variables.

Because you may want to say, "I no longer need this object here, I
relinquish all rights to it", so that if its reference count drops to
zero, it will be 'destructed'.  You can't FORCE it to be destructed, but
you can say you no longer need it in that scope.

For a simple integer variable, that is no big deal.  But if the object
is a network socket, or open file, or a huge matrix of floats, or any
other kind of heavyweight construct, you will often validly want to
relinquish it as soon as you can (and let the reference counting do its
job of reclaiming resources if possible).

-- 
Bay Area Python Interest Group - http://www.baypiggies.net/

Chad Netzer
(any opinion expressed is my own and not NASA's or my employer's)







More information about the Python-list mailing list