[Python-Dev] A grammatical oddity: trailing commas in argument lists -- continuation

R. David Murray rdmurray at bitdance.com
Mon Dec 13 16:51:19 CET 2010

On Mon, 13 Dec 2010 23:25:58 +1000, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Mon, Dec 13, 2010 at 9:44 PM, Jan Kaliszewski <zuo at chopin.edu.pl> wrote:
> > I think that seeing that:
> >
> > =A0 =A0def f(a, b): ...
> > =A0 =A0def f(a, *, b): ...
> > =A0 =A0def f(a, *args, b): ...
> > =A0 =A0x(1, 2, 3, 4, z=3D5)
> > =A0 =A0x(1, *(2,3,4), z=3D5)
> As per the closure of the affected tickets, the likely outcome of such
> a discussion would be the deprecation and subsequent removal of
> support for the following two options:
>     def f(a, b,): ...
>     x(1, 2, 3, 4, z=3D5,): ...
> Function arguments are not lists. Even when separated onto multiple
> lines, the closing "):" should remain on the final line with other
> content.
> That would be a lot of hassle to get rid of something that people
> probably aren't doing in the first place, though.

Counter examples from google code search:
        (also appears in json in the stdlib)
    http://www.google.com/codesearch/p?hl=en#algXCqBNNP0/vendor/python-clientform/ClientForm.py&q=^\ *\):&sa=N&cd=3&ct=rc
        (class def)

Not many, granted, but not zero, either, and I'm sure there are lots
more out there[*].  I do especially like the fact that there is one in the
stdlib :)

It seems like the status quo is fine.  I wouldn't object to it being
made more consistent.  I would object to removing the existing cases.

R. David Murray                                      www.bitdance.com

[*] code search's response to various regexes was somewhat surprising;
expressions I thought should have been supersets resulted in fewer
hits.  Nor could I think of a way to search for function invocations
ending with a comma.  Then again, I usually make lots of mistakes
with regexes.

More information about the Python-Dev mailing list