I am baffled by the trailing comma in a function parameter list:
def f( *args, ): pass
earns me a SyntaxError exception. In python 3, even this:
def f( *, arg = 1, ): pass
raises a syntax error exception. Both point to the closed parenthesis.
Removing the trailing comma, everything is quiet.
I am scratching my head on https://docs.python.org/3/reference/compound_stmts.html#function-definitions but it is somehow beyond me (and possibly also wrong... at least, in my browser's rendering I can't pair the last closing parenthesis in the parameter_list definition).
Am I doing something wrong?
I am the
def f(*,
a: "doc A" = 1,
b: "doc B" = 2,
c: "doc C" = 3,
d: "doc D" = 4,
# ... and maybe more,
)
type of person, and this issue kind-of annoys me (maybe that is the wrong part, and I should become the , a: "doc A" = 1 type of person - but it looks weird to me).
Using python as distributed in Gentoo ebuilds dev-lang/python 2.7.12 and 3.5.2 (from http://www.python.org).
Support for trailing commas following a catch-all argument was added in python 3.6.
It is not supported in 3.5 which explains your SyntaxError.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With