def instrument_operator_hooks(cls):

    def add_hook(name):
        operator_func = getattr(operator, name.strip('_'), None)
existing = getattr(cls, name, None)

def op_hook(self, *args, **kw):
    print('Hooking into {}'.format(name))
self._function = operator_func
self._params = args, kw
if existing is not None:
    return existing(self, *args, **kw)
raise AttributeError(name)
try:
    setattr(cls, name, op_hook)
except (AttributeError, TypeError):
    pass
for hook_name in operator_hooks:
    add_hook(hook_name)
return cls
How to catch any method called on an object in python?