Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Класс в роли декоратора. Для канала PyWay.
# copyright
from functools import wraps
class Repeater:
def __init__(self, n):
self.n = n
def __call__(self, f):
def wrapper(*args, **kwargs):
for _ in range(self.n):
f(*args, **kwargs)
return wrapper
def foo():
# foo
# foo
# foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment