weakrefs to functions for observer pattern
Alex Martelli
aleax at mail.comcast.net
Thu Nov 3 00:24:14 EST 2005
Michael Schneider <michaelschneider at fuse.net> wrote:
> I would like to use weak refs in an observer pattern implementation.
> The problme that I have seems to be that weakrefs can't manage functions.
They can manage just fine functions written in *Python*, just not
"builtin functions*, i.e., ones written in *C*. Just wrap any builtin
function you need to register as observer into a tiny Python-coded
wrapper and live happily ever after.
...
> Not all objects can be weakly referenced; those objects which can
> include class instances, functions written in Python (but not in C),
Alex
More information about the Python-list
mailing list