[Python-Dev] PEP 362 Third Revision

Nick Coghlan ncoghlan at gmail.com
Fri Jun 15 05:21:20 CEST 2012


On Fri, Jun 15, 2012 at 11:37 AM, Yury Selivanov
<yselivanov.ml at gmail.com> wrote:
> On 2012-06-14, at 7:16 PM, Nick Coghlan wrote:
>
>> POSITIONAL_ONLY
>> POSITIONAL_OR_KEYWORD
>> VAR_POSITIONAL
>> KEYWORD_ONLY
>> VAR_KEYWORD
>
> I like those.  A bit too lengthy and verbose, but the names
> are consistent.

In this case, I'm willing to trade a bit of verbosity for accuracy. It
also suggests a possible, more explicit name for the attribute:
"binding".

Parameter.binding - describes how argument values are bound to the parameter

    POSITIONAL_ONLY - value must be supplied as a positional argument [1]
    POSITIONAL_OR_KEYWORD - value may be supplied as either a keyword
or positional argument [2]
    KEYWORD_ONLY - value must be supplied as a keyword argument [3]
    VAR_POSITIONAL - a tuple of positional arguments that aren't bound
to any other parameter [4]
    VAR_KEYWORD - a dict of keyword arguments that aren't bound to any
other parameter [5]

    [1] Python has no explicit syntax for defining positional only
parameters, but they may be implemented by processing the contents of
a VAR_POSITIONAL parameter and customising the contents of
__signature__. Many builtin and extension module functions (especially
those that accept only one or two parameters) accept positional-only
parameters.
    [2] This is the standard binding behaviour for functions
implemented in Python
    [3] Keyword only parameters are those which appear after a "*" or
"*args" entry in a Python function definition. They may also be
implemented by processing the contents of a VAR_KEYWORD parameter and
customising the contents of __signature__.
    [4] This corresponds to a "*args" parameter in a Python function definition
    [5] This corresponds to a "**kwds" parameter in a Python function definition

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list