Module (35%)
Section (100%)

The last example in this section shows how to combine *args, a key word, and **kwargs in one definition:

def combiner(a, b, *args, c=20, **kwargs): super_combiner(c, *args, **kwargs) def super_combiner(my_c, *my_args, **my_kwargs): print('my_args:', my_args) print('my_c:', my_c) print('my_kwargs', my_kwargs) combiner(1, '1', 1, 1, c=2, argument1=1, argument2='1')

Result:

my_args: (1, 1) my_c: 2 my_kwargs {'argument1': 1, 'argument2': '1'}

output


As you can see, Python offers complex parameter handling:

  • positional arguments (a,b) are distinguished from all other positional arguments (args)
  • the keyword 'c' is distinguished from all other keyworded parameters.

Now that we know the purpose of special parameters, we can move on to decorators that make intensive use of those parameters.