*args, **kargs in function

Special forms of parameters:

*args: any number of positional arguments packed into a tuple

**kwargs: any number of keyword arguments packed into a dictionary

e.g.

1
2
3
4
5
def (*args, **kwargs):
print('args are', args)
print('kwargs are', kwargs)
variable_args('one', 'two', x=1, y=2, z=3)

Result

1
2
args is ('one', 'two')
kwargs is {'y': 2, 'x': 1, 'z': 3}