The joys of weakrefs... references to instance methods (callbacks)

Patrick K. O'Brien pobrien at
Mon Feb 11 14:55:33 EST 2002

You might find this useful:

This module,, provides global signal dispatching services
suitable for a wide variety of purposes, similar to Model-View-Controller or
Model-View-Presenter patterns. This particular implementation allows a
looser coupling than most Observer patterns. It also does transparent
cleanup through the use of weak references and weak reference callbacks.
This version defaults to using weak references, but provides an option to
not use weak references for those cases where weak references are
problematic (lambdas and such).

Patrick K. O'Brien

"Mike C. Fletcher" <mcfletch at> wrote in message
news:mailman.1013255897.29941.python-list at
> Sat down to work out a model-view framework for a little application and
> had one of those "oh, darn, didn't think that out very carefully"
> moments.  You see, I was planning on doing a fairly straightforward
> callback-passing mechanism:
> Yes, it's slightly different semantics than weakref, but it's actually
> useful in the real world ;) .  Anyway, thought I'd share the code so
> that people can object that it's a tool of the devil :) .  If the powers
> that be want to point out any reasons why I shouldn't do this, would
> love to hear it before my house of cards goes *phoosh*.
> Enjoy all,
> Mike
> _______________________________________
>    Mike C. Fletcher

More information about the Python-list mailing list