exercise 11 added
This commit is contained in:
1 parent
e9f9d24c96
commit
dbf00aca26
1 file changed
+21
@@ -0,0 +1,21 @@
|
|||||||
|
import functools
|
||||||
|
|
||||||
|
def run_once(f):
|
||||||
|
already_run = False
|
||||||
|
|
||||||
|
@functools.wraps(f)
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
nonlocal already_run
|
||||||
|
|
||||||
|
if not already_run:
|
||||||
|
already_run = True
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
@run_once
|
||||||
|
def test():
|
||||||
|
print("Hello World!")
|
||||||
|
|
||||||
|
test()
|
||||||
|
test()
|
||||||
Reference in new issue
Block a user