Adam Bartoš added the comment: Some remarks:
• A trailing comma after a non-empty argument list is allowed in every call form, including class statement and optional call in decorator syntax. In the grammar, this correponds to `arglist`. • In function definition, trailing comma is allowed only if there is no star before: def f(a, b, c,): # allowed def f(a=1, b=2, c=3,): # allowed def f(*args,): # disallowed def f(**kwargs,): # disallowed def f(*, a, b, c,): # disallowed The last example is what bothers me. The presence of the star should not affect whether trailing comma is allowed or not. If `f(a, b, c,)` is allowed as a call, it should be allowed in a definition, and if def `f(a, b, c,)` is allowed, `f(*, a, b, c,)` should be allowed as well. In the grammar this corresponds to `typedargslist` for functions and `varargslist` for lambdas. • A traling comma is allowed in tuples, lists, dicts, sets, the corresponding comprehensions, augmented assignments, and subscripts. It is also allowed in `from module import names` in the names part, but only if there are surrounding parentheses. Also a trailing semicolon is allowed for multiple statements in one line. • A traling comma is *not* allowed in with statement, `import modules`, assert statement (there is just optional second argument), global and nonlocal statements. In all these cases surrounding parentheses are not allowed. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9232> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com