Combine python function arguments into one variable

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

Combine python function arguments into one variable
Combine multiple python files into one python file
About function arguments (python)
Python: About function arguments
[Python & Unix] Combine multiple PDF files into one.
Combine accessors into one method
Included notation in Python function arguments
[Python] Function arguments * (star) and ** (double star)
python function ①
[Python] function
python function ②
Python underscore variable
Automatically register function arguments to argparse in Python
python enumerate function
Example of taking Python> function> * args as arguments
Python> function> Closure
[Python] Generator function
Python> function> Inner function
Python function decorator
Combine multiple csv files into one csv file with python (assuming only one line of header)
Python that merges a lot of excel into one excel
Execute Python function from Powershell (how to pass arguments)
Combine multiple Excel files loaded using pandas into one
python variable expansion, format
One liner in Python
Python variable length assignment?
Function execution time (Python)
Python print function (sequel)
Time floor function (Python)
Summary of Python arguments
A function that divides iterable into N pieces in Python