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

Michael Foord fuzzyman at voidspace.org.uk
Mon Dec 13 14:39:44 CET 2010

On 13/12/2010 13:25, 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.


For very long signatures I still mildly prefer this:

def f(self, first, second, third, fourth,
foo=None, bar=None, baz=None,
spam=None, eggs=None, ham=None

Over putting the closing paren: on the last line of the def.

Of course not having such long signatures is even more preferable, but 
*sometimes* they are needed.

All the best,

Michael Foord
> That would be a lot of hassle to get rid of something that people
> probably aren't doing in the first place, though.
> Regards,
> Nick.



READ CAREFULLY. By accepting and reading this email you agree,
on behalf of your employer, to release me from all obligations
and waivers arising from any and all NON-NEGOTIATED agreements,
licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap,
confidentiality, non-disclosure, non-compete and acceptable use
policies (”BOGUS AGREEMENTS”) that I have entered into with your
employer, its partners, licensors, agents and assigns, in
perpetuity, without prejudice to my ongoing rights and privileges.
You further represent that you have the authority to release me
from any BOGUS AGREEMENTS on behalf of your employer.

More information about the Python-Dev mailing list