I have a method which looks like this:
def order_by(*args):
print list(args)
Is there a way I could pass a list of three items and have each item in the list passed as an individual parameters?
params = ['a', 'b', 'c']
would equate to
order_by('a', 'b', 'c')
Any ideas?
The
*argumentssyntax can be used for calling functions too, providedparamsis an iterable:See the calls syntax specification.
For an actual dictionary, use the
**kwargssyntax:where
somemethodacceptsa,bandcarguments or has a**kwcatch-all argument. Note that**paramsdoes not work if all your function defines is a*argspositional argument catch-all.