Issue 1531016: Comma not allowed at the end of argument list for **argument (original) (raw)
This tells it all:
str('sdfd', **a,) File "", line 1 str('sdfd', **a,) ^ SyntaxError: invalid syntax
str('sdfd', *a,) File "", line 1 str('sdfd', *a,) ^ SyntaxError: invalid syntax
While the docs tell otherwise:
http://docs.python.org/ref/calls.html
While having arguments after ** doesn't make sense, comma after ANY kinds of arguments seem to be more consistent.
This behavior seems as intended. According to the docs (http://docs.python.org/ref/calls.html):
A trailing comma may be present after the positional and keyword arguments but does not affect the semantics. [snip] Formal parameters using the syntax "*identifier" or "**identifier" cannot be used as positional argument slots or as keyword argument names.
I'm having trouble with what this actually means. However, the relevant section in the Grammar looks like this:
arglist: (argument ',')* (argument [',']| '*' test [',' '' test] | '' test )
It looks like this logic was explicitly coded.
If this is determined to be a bug, we can just add [','] after the test in both cases.