I am following this answer in order to decorate all methods of a class. This is my version of the code:
def decorate_object_methods(object_to_decorate, decorator):
for name in dir(object_to_decorate):
attr = getattr(object_to_decorate, name)
if callable(attr):
wrapped = decorator(attr)
setattr(object_to_decorate, name, wrapped)
The problem is that I am getting this exception in the last sentence of the method:
TypeError: __class__ must be set to a class, not 'function' object
I can't find what I'm doing wrong