Weakref.ref callbacks and eliminating __del__ methods

Mike C. Fletcher mcfletch at rogers.com
Sun Jan 23 19:13:54 EST 2005


Alex Martelli wrote:

>Mike C. Fletcher <mcfletch at rogers.com> wrote:
>
>  
>
>>        weakref.ref( self, self.close )
>>
>>but the self.close reference in the instance is going away *before* the
>>object is called.
>>    
>>
>
>Uh -- what's holding on to this weakref.ref instance?  I guess the
>weakreference _itself_ is going away right after being created...
>  
>
You know, you're right.  I'd been thinking (not-very-clearly) that 
registering the callback would keep the reference alive until it was 
called, guess I'm too used to PyDispatcher's operation.  Urgh, that's 
seriously annoying, requires storing the callback somewhere external.

Back to __del__ I suppose.

Thanks Alex,
Mike

 
________________________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com




More information about the Python-list mailing list