Message248399
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. |
|
Date |
User |
Action |
Args |
2015-08-11 10:21:42 | Drekin | set | recipients:
+ Drekin, loewis, rhettinger, mark.dickinson, ncoghlan, belopolsky, larry, eric.smith, rbcollins, zuo, Trundle, gstarck, martin.panter, pconnell |
2015-08-11 10:21:42 | Drekin | set | messageid: <1439288502.57.0.445470972915.issue9232@psf.upfronthosting.co.za> |
2015-08-11 10:21:42 | Drekin | link | issue9232 messages |
2015-08-11 10:21:41 | Drekin | create | |
|