Design thought for callbacks

Cem Karan cfkaran2 at gmail.com
Sun Feb 22 07:16:14 EST 2015


On Feb 21, 2015, at 12:08 PM, Marko Rauhamaa <marko at pacujo.net> wrote:

> Steven D'Aprano <steve+comp.lang.python at pearwood.info>:
> 
>> Other than that, I cannot see how calling a function which has *not*
>> yet been garbage collected can fail, just because the only reference
>> still existing is a weak reference.
> 
> Maybe the logic of the receiving object isn't prepared for the callback
> anymore after an intervening event.
> 
> The problem then, of course, is in the logic and not in the callbacks.

This was PRECISELY the situation I was thinking about.  My hope was to make the callback mechanism slightly less surprising by allowing the user to track them, releasing them when they aren't needed without having to figure out where the callbacks were registered.  However, it appears I'm making things more surprising rather than less.

Thanks,
Cem Karan


More information about the Python-list mailing list