import time def loop(delay=1): def middle(func): def inner(self, *args, **kwargs): time.sleep(delay) return func(self, *args, **kwargs) return inner return middle class A(): @loop(delay=3) def a(self,num): print(num) A().a(5)