You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
405 B
33 lines
405 B
def adder():
|
|
n = 0
|
|
|
|
def add():
|
|
nonlocal n
|
|
n += 1
|
|
return n
|
|
|
|
return add
|
|
|
|
|
|
def retry(n: int = 5):
|
|
def deco(f):
|
|
def inner(*args, **kwargs):
|
|
for _ in range(n):
|
|
f(*args, **kwargs)
|
|
|
|
return inner
|
|
|
|
return deco
|
|
|
|
|
|
# @retry(5)
|
|
def foo():
|
|
print("Hello world!")
|
|
|
|
|
|
foo = (retry(5))(foo)
|
|
|
|
|
|
@retry(15)
|
|
def bar():
|
|
print("Bar")
|
|
|