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

Tres Seaver tseaver at palladion.com
Mon Dec 13 14:42:34 CET 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/13/2010 08:25 AM, Nick Coghlan wrote:
> On Mon, Dec 13, 2010 at 9:44 PM, Jan Kaliszewski <zuo at chopin.edu.pl> wrote:
>> I think that seeing that:
>>
>>    def f(a, b): ...
>>    def f(a, *, b): ...
>>    def f(a, *args, b): ...
>>    x(1, 2, 3, 4, z=5)
>>    x(1, *(2,3,4), z=5)
> 
> 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=5,): ...
> 
> 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.

I actually make use of the feature when dealing with APIs which both a)
take lots of arguments (more than fit comfortably on two lines at
whatever indentation they are called), and b) have optional trailing
arguments:  I always leave the trailing comma in place in such cases,
with the closing paren on the following line, so that adding or removing
an argument at the end of the list stays consistent (the diffs are
better, too, when I use this pattern).



Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0GIsoACgkQ+gerLs4ltQ5HLwCfYFSyVrFtt04h6a39hyK6BD2c
t8oAoJdXNS7wIsjF34ZiOQCwQGq9Qs2v
=ZWqW
-----END PGP SIGNATURE-----



More information about the Python-Dev mailing list