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

Glenn Linderman v+python at g.nevcal.com
Tue Dec 14 00:46:46 CET 2010


On 12/13/2010 1:55 PM, Raymond Hettinger 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.

It seems to me that a trailing comma, especially in the case of one 
parameter per line, is a deliberate comma-for-the-future.  It's a good 
reminder that you are dealing with a list of some sort, rather than a 
statement, when you look at just one parameter on the line.

Especially if the ) is on the next line, which I prefer.

Yes, a parameter list is not a python list, nor a python tuple, but it 
is still a generic, comma-separated list, and all such are more 
conveniently dealt with, in the multi-line case, if trailing commas are 
permitted.  And, of course, the one-entry tuple needs the comma to 
differentiate it from some other expression, forcing the trailing comma 
into the syntax... so there can be no consistent rule for all commas 
that doesn't permit trailing commas.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20101213/a49de9cc/attachment.html>


More information about the Python-Dev mailing list