[Python-Dev] A grammatical oddity: trailing commas in argument lists. (original) (raw)

Eric Smith eric at trueblade.com
Fri Jul 9 23:30:35 CEST 2010


On 7/9/2010 4:42 PM, Georg Brandl wrote:

Am 09.07.2010 22:26, schrieb Mark Dickinson:

On Fri, Jul 9, 2010 at 8:37 PM, Dino Viehland<dinov at microsoft.com> wrote:

Terry wrote:

This violates the important principle that allowed def and call arg sequences should match to the extent sensible and possible. In this sense, the SyntaxError is a bug. So I would fix this now for 3.2 and notify the other implementors.

+1 on fixing it - trailing commas are awesome. I'm always annoyed in C# where I frequently can't use them. This seems like a bug fix level change that should be easy for the other implementations to fix. Thanks for all the feedback. If the grammar is changed to allow "def f(*, a,): pass", that still leaves some more open questions: which of the following should be valid? (1) def f(*args,): pass (2) def f(**kwargs,): pass (3) def f(*,): pass IMO all of them (though as you mention, (3) doesn't matter.)

Agreed. It's one less thing to explain: "You can have a trailing comma in an argument list, unless there's a bare star, and in that case you can't have a comma; and also if ...". Ick.

Eric.



More information about the Python-Dev mailing list