Feed Python Function With A Variable Number Of Arguments
I have a script that reads a variable number of fields from an input file and pass them to a function as arguments. For example: file 1 with fields: A,B and C => function(A,B
Solution 1:
you should use args and kwargs like this:
deffoo(*args, **kwargs):
pass
in this way you can get positional and named parameters, args should be a list of values, holding the positional arguments, kwargs should be a dictionary, its keys the argument name with its value
Post a Comment for "Feed Python Function With A Variable Number Of Arguments"