From a860c01a890e5c80c94477b6012fabfaaf0a81e1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 8 Dec 2023 11:11:44 +0100 Subject: [PATCH] add prototype --- prototyping/dependency_injection.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 prototyping/dependency_injection.py diff --git a/prototyping/dependency_injection.py b/prototyping/dependency_injection.py new file mode 100644 index 0000000..dbd3760 --- /dev/null +++ b/prototyping/dependency_injection.py @@ -0,0 +1,19 @@ +import inspect + +a = 2 +b = 3 +c = 4 + + +def func(a: int, c: int) -> int: + return a + c + + +arg_names = inspect.getfullargspec(func).args +print(arg_names) # ['a', 'c'] + +arguments = {arg: globals()[arg] for arg in arg_names if arg in globals()} +print(arguments) # {'a': 2, 'c': 4} + +result = func(**arguments) +print(result) # 6