- *
- **
- *args
- **kwargs
Variable length argument list with * and **
examples/advanced/varargs.py
def f(a, b=1, *args, **kwargs): print('a: ', a) print('b: ', b) print('args: ', args) print('kwargs:', kwargs) return a + b f(2, 3, 4, 5, c=6, d=7) print() f(2, c=5, d=6) print() f(10)
a: 2 b: 3 args: (4, 5) kwargs: {'c': 6, 'd': 7} a: 2 b: 1 args: () kwargs: {'c': 5, 'd': 6} a: 10 b: 1 args: () kwargs: {}