Notification when reference count goes to 0?

Bengt Richter bokr at oz.net
Mon Dec 23 21:58:51 EST 2002


On Mon, 23 Dec 2002 06:37:15 GMT, "Robert Oschler" <Oschler at earthlink.net> 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.
>
Look into the weakref module. I think you can build something using
stuff from there, depending on what you want to do.

Regards,
Bengt Richter



More information about the Python-list mailing list