Design thought for callbacks

Gregory Ewing greg.ewing at canterbury.ac.nz
Tue Feb 24 00:45:18 EST 2015


Cem Karan wrote:
> On Feb 22, 2015, at 5:15 AM, Gregory Ewing <greg.ewing at canterbury.ac.nz>
> wrote:
> 
>> Perhaps instead of registering a callback function, you should be
>> registering the listener object together with a method name.
> 
> 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.

It would be weird and unpythonic to have to register both
an object and an unbound method, and if you use a bound
method you can't keep a weak reference to it.

-- 
Greg



More information about the Python-list mailing list