キーワード引数を受け取る関数
関数の引数の前にアスタリスクを2個付けるとキーワード指定した未定義の
引数を受け取れるみたい。
>>> def hoge2(a,b, **value): ... print a,b,value ... >>> hoge2(1,2,c=3,d=4) 1 2 {'c': 3, 'd': 4} >>> hoge2(1,2,3,4) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: hoge2() takes exactly 2 arguments (4 given)
未定義の引数はvalueに辞書として代入されている。
キーワード指定しないとエラーになる。