def foo(arg1, arg2, arg3, *args, kwarg1="FOO", kwarg2="BAR", kwarg3="BAZ"): pass print(foo.__kwdefaults__)
Output (Python 3):
{'kwarg1': 'FOO', 'kwarg2': 'BAR', 'kwarg3': 'BAZ'}
Since *args will swallow all arguments without a keyword, the arguments after that must be passed with the keywords. See PEP 3102 .
source share