def register_callback(self, key, callback, force=False):

        # Non-string keys are not allowed
        if type(key) is not str:
            raise TypeError("event non-string keys are not allowed")

        # And finally callback should be callable
        if not callable(callback):
            raise TypeError("event callback should be callable")

        # Check if callback has all three required parameters (key, value, timestamp)
        # When callback is class method should have 4 arguments (self, key, value, timestamp)
        if ismethod(callback):
            arg_count = callback.func_code.co_argcount
            if arg_count != 4:
                err_msg = "callback 'self.%s('%s', ...)' defined with %d arguments"% (callback.__name__, key, arg_count)
                err_msg += ", should have 4 arguments: self.%s(self, key, value, timestamp)"% callback.__name__
                raise TypeError(err_msg)

        # When callback is just a function should have 3 arguments func(key, value, timestamp)
        if isfunction(callback):
            arg_count = callback.func_code.co_argcount
            if arg_count != 3:
                err_msg = "callback '%s('%s', ...)' defined with %d arguments"% (callback.__name__, key, arg_count)
                err_msg += ", should have 3 arguments: %s(key, value, timestamp)"% callback.__name__
                raise TypeError(err_msg)

        if not force:
            # Event starting with '__' are reserved
            if key.startswith('__'):
                raise ValueError("event key starting with '__' are reserved")

            # We predefined few callbacks you can't use
            if key in self.__restricted_callbacks:
                raise ValueError("we predefined few callbacks you can't use e.g. '%s'"% key)

        self.__callbacks[key] = callback
Delete several keys from a dict, ignoring those that don't exist.
dataset/ETHPy150Open ARMmbed/htrun/mbed_host_tests/host_tests/base_host_test.py/HostTestCallbackBase.register_callback--crossover with--dataset/ETHPy150Open mikeorr/WebHelpers2/webhelpers2/containers.py/del_keys