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: "def f(*args, ): pass" does not compile
Type: Stage:
Components: Versions: Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Allow trailing comma in any function argument list.
View: 9232
Assigned To: Nosy List: Drekin, martin.panter
Priority: normal Keywords:

Created on 2015-07-21 10:43 by Drekin, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg247023 - (view) Author: Adam Bartoš (Drekin) * Date: 2015-07-21 10:43
I think that a trailing comma in function definition should be allowed also after *. 

Current situation with definitions:
def f(*args, ): pass # SyntaxError
def f(*, ): pass # SyntaxError
def f(*, a, ): pass # SyntaxError
def f(*, a=2, ): pass # SyntaxError

def f(a, ): pass # Ok
def f(, ): pass # SyntaxError – this should probably stay error

Corresponding calls:
f(*args, ) # Ok
f(*args, a, ) # Ok
f(*args, a=2, ) # Ok 

f(a, ) # Ok
f(, ) # SyntaxError – this is why the corresponding def behavior should stay

My use case:
def f(*, 
        long = 1, 
        list = 2, 
        of = 3, 
        kwonly = 4, 
        parameters = 5, 
    ):
    ...
msg247027 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-07-21 12:53
See existing Issue 9232. I agree with your use case, but apparently this is controversial.

Playing the devil’s advocate here, the function calls involving *unpacking and a trailing comma only became valid in 3.5. I think this was a side effect of the new f(*args, *more) syntax, though I don’t know if it was intentional. It was not mentioned in PEP 448 that I can see.
History
Date User Action Args
2022-04-11 14:58:19adminsetgithub: 68865
2015-07-21 12:53:37martin.pantersetstatus: open -> closed

superseder: Allow trailing comma in any function argument list.
versions: + Python 3.5
nosy: + martin.panter

messages: + msg247027
resolution: duplicate
2015-07-21 10:43:42Drekincreate