[Python-3000] atexit module problems/questions

skip at pobox.com skip at pobox.com
Sun Aug 5 04:51:13 CEST 2007


    >> I can see a situation where you might register the same function
    >> multiple times with different argument lists, yet unregister takes
    >> only the function as the discriminator.

    Greg> One way to fix this would be to remove the ability to register
    Greg> arguments along with the function. It's not necessary, as you can
    Greg> always use a closure to get the same effect. Then you have a
    Greg> unique handle for each registered callback.

Then you need to hang onto the closure.  That might be some distance away
from the point at which the function was registered.  Returning a unique id
corresponding to the specific call to atexit.register is much simpler the
than forcing the caller to build a closure.

Skip



More information about the Python-3000 mailing list