Ubuntu 12.04, python 3.2.3
Optional trailing comma causes syntax error if used for keyword-only argument list:
These are OK --
def f(a, b,): pass
def f(a, b=None,): pass
These triggers syntax error --
def f(a, *, b,): pass
def f(a, *, b=None,): pass
python 3.1 and 3.2 shows this error, not tested for 3.3 yet.
I could be misinterpreting the documentation, but it looks to me like the examples given are behaving as documented:
parameter_list ::= (defparameter ",")*
( "*" [parameter] ("," defparameter)*
[, "**" parameter]
| "**" parameter
| defparameter [","] )
(from http://docs.python.org/dev/reference/compound_stmts.html#function-definitions )
The relevant clause in the above looks to be the following, which can't give rise to a trailing comma:
"*" [parameter] ("," defparameter)* [, "**" parameter]