weakrefs and bound methods

Alex Martelli aleax at mac.com
Sun Oct 7 15:55:30 EDT 2007


Mathias Panzenboeck <e0427417 at student.tuwien.ac.at> wrote:

> Marc 'BlackJack' Rintsch wrote:
> > ``del b`` just deletes the name `b`.  It does not delete the object.
> > There's still the name `_` bound to it in the interactive interpreter.
> > `_` stays bound to the last non-`None` result in the interpreter.
> 
> Actually I have the opposite problem. The reference (to the bound method)
> gets lost but it shouldn't!

weakrefs to bound methods require some subtlety, see
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81253> (or what
I believe is the better treatment of this recipe in the printed edition
of the Python Cookbook -- of course, being the latter's editor, I'm
biased;-).


Alex



More information about the Python-list mailing list