[Python-3000] weakrefs of bound methods

Phillip J. Eby pje at telecommunity.com
Sun Feb 17 16:10:59 CET 2008


At 09:29 AM 2/17/2008 +0000, Nick Craig-Wood wrote:
>On Fri, Feb 15, 2008 at 01:20:03PM -0800, Guido van Rossum wrote:
> > But maybe given how rare the use case is, it would be easier to just
> > create a custom class in weakref.py that does what Nick requested.
>
>I still don't like the silent failure, but a noisy failure and a
>custom class would be great.
>
>FYI here is the class I was writing which tripped me up.  I created
>this to untangle some spaghetti code in a reasonably complex GUI
>application I'm writing.
>
>Instead of there being lots of hardcoded callbacks in the GUI objects
>I made a central registry which made the code a lot cleaner.  The
>weakrefs avoided registration and deregistration.

You might want to check this out:

http://pypi.python.org/pypi/PyDispatcher

"""Included in the package are the robustapply and saferef modules, 
which provide the ability to selectively apply arguments to callable 
objects and to reference instance methods using weak-references."""



More information about the Python-3000 mailing list