Notification when reference count goes to 0?

Ben Leslie benno at sesgroup.net
Mon Dec 23 01:52:46 EST 2002


On Mon, 23 Dec 2002, Robert Oschler wrote:

> Is there a way to get notification when the reference count goes to 0 on an
> object? The only thing I miss from C++ is destructors.  If there was a way
> to get notified when an object's reference count went to 0, the automatic
> release of associated resources would be possible, yes?  Just to be
> explicit, I'm not interested in garbage collection based finalization, as
> everyone knows the timing or even the occurrence of such an event comes
> under the heading of 'unspecified behavior', at least with Java it is.

I'm fairly certain this is what the __del__() method is used for.

Benno
(who likes instances cleaning up after themselves, without having to
do it explicitly.)




More information about the Python-list mailing list