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.

classification
Title: Comma not allowed at the end of argument list for **argument
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, rnd0110, sean_gillespie
Priority: low Keywords:

Created on 2006-07-29 20:21 by rnd0110, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg29379 - (view) Author: Roman Suzi (rnd0110) Date: 2006-07-29 20:21
This tells it all:

>>> str('sdfd', **a,)
  File "<stdin>", line 1
    str('sdfd', **a,)
                   ^
SyntaxError: invalid syntax

>>> str('sdfd', *a,)
  File "<stdin>", line 1
    str('sdfd', *a,)
                   ^
SyntaxError: invalid syntax

While the docs tell otherwise:

http://docs.python.org/ref/calls.html

While having arguments after ** doesn't make sense,
comma after ANY kinds of arguments seem to be more
consistent.


msg29380 - (view) Author: Sean Gillespie (sean_gillespie) Date: 2007-03-16 14:42
This behavior seems as intended.  According to the docs (http://docs.python.org/ref/calls.html):

A trailing comma may be present after the positional and keyword arguments but does not affect the semantics. 
[snip]
Formal parameters using the syntax "*identifier" or "**identifier" cannot be used as positional argument slots or as keyword argument names.

I'm having trouble with what this actually means.  However, the relevant section in the Grammar looks like this:

arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test )

It looks like this logic was explicitly coded.

If this is determined to be a bug, we can just add [','] after the test in both cases.
msg82291 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-02-17 01:37
Agreed. Not a bug.
History
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43745
2009-02-17 01:37:16benjamin.petersonsetstatus: open -> closed
resolution: not a bug
messages: + msg82291
nosy: + benjamin.peterson
2006-07-29 20:21:02rnd0110create