Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 623 Bytes

13_args_and_kwargs_mistakes.md

File metadata and controls

18 lines (15 loc) · 623 Bytes

First let us define a function and call it in a normal way.

def print_three_things(a, b, c): ... print '%s -- %s -- %s' % (str(a), str(b), str(c))

print_three_things([], 4, 'hello') [] -- 4 -- hello

The following is obviously wrong, since it tries to pass in a specific argument but at the same time expand it to be a list of unnamed arguments:

print_three_things(a = *[1, 2, 3]) Traceback (most recent call last): ... SyntaxError: invalid syntax

The same applies to the following:

print_three_things(a = **{'a': 1, 'b': 2, 'c': 3}) Traceback (most recent call last): ... SyntaxError: invalid syntax