add prototype
This commit is contained in:
parent
50eea28585
commit
a860c01a89
1 changed files with 19 additions and 0 deletions
19
prototyping/dependency_injection.py
Normal file
19
prototyping/dependency_injection.py
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue