Is it possible to dynamically set the name of an argument being passed into a function?
like this:
def func(one=None, two=None, three=None, four=None):
...
params = ("one","two","three","four",)
for var in params:
tmp = func(var=value)
Is it possible to dynamically set the name of an argument being passed into a function?
like this:
def func(one=None, two=None, three=None, four=None):
...
params = ("one","two","three","four",)
for var in params:
tmp = func(var=value)
In case someone is looking for passing dynamic parameters but those parameters are not key value pair arguments. You can create a dynamic
list
and pass it like this in function call
*list
e.g.
def fun(a,b,c,d):
pass
dynamic_list = []
if True:
dynamic_list.append(2)
if True:
dynamic_list.append(2)
if True:
dynamic_list.append(2)
if True:
dynamic_list.append(2)
fun(*dynamic_list)
Yes, with keyword argument unpacking:
Output: