This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Drekin
Recipients Drekin, Trundle, belopolsky, eric.smith, gstarck, larry, loewis, mark.dickinson, martin.panter, ncoghlan, pconnell, rbcollins, rhettinger, zuo
Date 2015-08-11.10:21:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1439288502.57.0.445470972915.issue9232@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-08-11 10:21:42Drekinsetrecipients: + Drekin, loewis, rhettinger, mark.dickinson, ncoghlan, belopolsky, larry, eric.smith, rbcollins, zuo, Trundle, gstarck, martin.panter, pconnell
2015-08-11 10:21:42Drekinsetmessageid: <1439288502.57.0.445470972915.issue9232@psf.upfronthosting.co.za>
2015-08-11 10:21:42Drekinlinkissue9232 messages
2015-08-11 10:21:41Drekincreate