[Python-Dev] PEP 3102: Keyword-only arguments

Terry Reedy tjreedy at udel.edu
Mon May 1 03:08:57 CEST 2006


"Nick Coghlan" <ncoghlan at gmail.com> wrote in message 
news:44549922.7020109 at gmail.com...
> Terry Reedy wrote:
>> "Talin" <talin at acm.org> wrote in message 
>> news:4453B025.3080100 at acm.org...
>>>     Now, suppose you wanted to have 'key' be a keyword-only argument.
>>
>> Why?  Why not let the user type the additional argument(s) without the
>> parameter name?

Like Martin, you clipped most of the essential context of my question: 
Talin's second proposal.
>>>    The second syntactical change is to allow the argument name to
>>>    be omitted for a varargs argument:
>>>        def compare(a, b, *, key=None):
>>>    The reasoning behind this change is as follows.  Imagine for a
>>>    moment a function which takes several positional arguments, as
>>>    well as a keyword argument:
>>>        def compare(a, b, key=None):

Again I ask, why would one want that?  And, is the need for that so strong 
as to justify introducing '*' as a pseudoparameter?

> Because for some functions (e.g. min()/max()) you want to use *args, but
> support some additional keyword arguments to tweak a few aspects of the
> operation (like providing a "key=x" option).

This and the rest of your 'explanation' is about Talin's first proposal, to 
which I already had said "The rationale for this is pretty obvious".

Terry Jan Reedy





More information about the Python-Dev mailing list