classification
Title: optional comma inside function argument list triggers syntax error
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Allow trailing comma in any function argument list.
View: 9232
Assigned To: Nosy List: Inyeol.Lee, chris.jerdonek
Priority: normal Keywords:

Created on 2012-10-25 06:24 by Inyeol.Lee, last changed 2012-10-25 07:51 by chris.jerdonek. This issue is now closed.

Messages (3)
msg173735 - (view) Author: Inyeol Lee (Inyeol.Lee) Date: 2012-10-25 06:24
Ubuntu 12.04, python 3.2.3

Optional trailing comma causes syntax error if used for keyword-only argument list:

These are OK --
def f(a, b,): pass
def f(a, b=None,): pass

These triggers syntax error --
def f(a, *, b,): pass
def f(a, *, b=None,): pass

python 3.1 and 3.2 shows this error, not tested for 3.3 yet.
msg173741 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-10-25 07:46
I could be misinterpreting the documentation, but it looks to me like the examples given are behaving as documented:

parameter_list ::=  (defparameter ",")*
                    (  "*" [parameter] ("," defparameter)*
                    [, "**" parameter]
                    | "**" parameter
                    | defparameter [","] )

(from                     http://docs.python.org/dev/reference/compound_stmts.html#function-definitions )

The relevant clause in the above looks to be the following, which can't give rise to a trailing comma:

"*" [parameter] ("," defparameter)* [, "**" parameter]
msg173742 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-10-25 07:51
Duplicate of issue 9232 (enhancement request).
History
Date User Action Args
2012-10-25 07:51:34chris.jerdoneksetstatus: open -> closed
superseder: Allow trailing comma in any function argument list.
messages: + msg173742

resolution: duplicate
stage: resolved
2012-10-25 07:46:01chris.jerdoneksetnosy: + chris.jerdonek
messages: + msg173741
2012-10-25 06:24:20Inyeol.Leecreate