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

Raymond Hettinger raymond.hettinger at gmail.com
Tue Dec 14 07:21:33 CET 2010

On Dec 13, 2010, at 2:16 PM, Guido van Rossum wrote:

> On Mon, Dec 13, 2010 at 1:55 PM, Raymond Hettinger
> <raymond.hettinger at gmail.com> wrote:
>> It seems to me that a trailing comma in an argument list is more likely to be a user error than a deliberate comma-for-the-future.
> Really? Have you observed this? Even if it was inserted by mistake, it
> is harmless.

I only have one data point, my own mistakes.  The SyntaxError
has occasionally been helpful to me when working out a function
signature or to detect a copy and paste error.  In both cases,
it meant that there was supposed to be another argument
and it had been either forgotten or mispasted.

Also, if I were reviewing someone else's code and saw
a trailing comma in a function definition, it would
seem weird and I would wonder if the author intended
a different signature.

FWIW, this isn't important to me at all.  Was just noting
my own experience.  Don't put assign much weight to it,
I don't have much of a preference either way.

> Python has a long tradition of allowing redundant
> trailing commas in comma-separated lists, and it is habit-forming.

Right.  I see that in the wild quite often and use it myself.


More information about the Python-Dev mailing list