Hello sekitaka.
This is a method to use all the arguments in one dict in a function with many arguments in python.
It seems that dict can be expanded by using the **
operator, so use it to apply as follows.
def my_function(foo, bar):
print "foo is {0}, bar is {1}".format(foo, bar)
params = {
'foo': 'FOO',
'bar': 'BAR',
}
#Pass foo of params as argument foo and bar as well
my_function(**params)
It would be nice if you could easily change only the values of some arguments with if.
Recommended Posts