◐ Shell
clean mode source ↗

Issue 24677: "def f(*args, ): pass" does not compile

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, 
    ):
    ...
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.