Capturing arguments
We can capture the remainder of arguments:
def test(*args):
for arg in args:
print(f'We were given: {arg}\n')Or keyword arguments:
def test(**kwargs):
for (key, value) in kwargs.items():
print(f'{key} -> {value}')
test(deez = "nuts")You could also define optional arguments:
def test(opt = False, **kwargs):
kwargs['opt'] = opt;
for (key, value) in kwargs.items():
print(f'{key} -> {value}')
test(deez = "nuts")