From dbf00aca26bd8b099e916298a445a6aafcc10526 Mon Sep 17 00:00:00 2001 From: heinleinju104093 Date: Thu, 12 Nov 2026 12:12:21 +0100 Subject: [PATCH] exercise 11 added --- src/functional/11_run_once.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/functional/11_run_once.py diff --git a/src/functional/11_run_once.py b/src/functional/11_run_once.py new file mode 100644 index 0000000..1b94826 --- /dev/null +++ b/src/functional/11_run_once.py @@ -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() \ No newline at end of file