How can I decorate an instance method with a decorator class?
tl;dr You can fix this problem by making the Timed class a descriptor and returning a partially applied function from __get__ which applies the Test object as one of the arguments, like this class Timed(object): def __init__(self, f): self.func = f def __call__(self, *args, **kwargs): print(self) start = dt.datetime.now() ret = self.func(*args, **kwargs) time = … Read more