On Feb 22, 2015, at 5:15 AM, Gregory Ewing <greg.ew...@canterbury.ac.nz> wrote:

> Frank Millman wrote:
>> "In order to inform users that certain bits of state have changed, I require 
>> them to register a callback with my code."
>> This sounds to me like a pub/sub scenario. When a 'listener' object comes 
>> into existence it is passed a reference to a 'controller' object that holds 
>> state. It wants to be informed when the state changes, so it registers a 
>> callback function with the controller.
> 
> Perhaps instead of registering a callback function, you
> should be registering the listener object together with
> a method name.
> 
> You can then keep a weak reference to the listener object,
> since if it is no longer referenced elsewhere, it presumably
> no longer needs to be notified of anything.

I see what you're saying, but I don't think it gains us too much.  If I store 
an object and an unbound method of the object, or if I store the bound method 
directly, I suspect it will yield approximately the same results.

Thanks,
Cem Karan
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to