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

Aahz aahz at pythoncraft.com
Sun Apr 30 06:30:15 CEST 2006


On Sat, Apr 29, 2006, Talin wrote:
>
> Specification
> 
>      Syntactically, the proposed changes are fairly simple.  The first
>      change is to allow regular arguments to appear after a varargs
>      argument:
> 
>          def sortwords(*wordlist, case_sensitive=False):
>             ...
> 
>      This function accepts any number of positional arguments, and it
>      also accepts a keyword option called 'case_sensitive'.  This
>      option will never be filled in by a positional argument, but
>      must be explicitly specified by name.
> 
>      Keyword-only arguments are not required to have a default value.
>      Since Python requires that all arguments be bound to a value,
>      and since the only way to bind a value to a keyword-only argument
>      is via keyword, such arguments are therefore 'required keyword'
>      arguments.  Such arguments must be supplied by the caller, and
>      they must be supplied via keyword.

You should show with simulated doctests what happens when you call
required keyword functions correctly and incorrectly.  You should also
show an example of a required keyword function where the parameter does
not have a default value.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Argue for your limitations, and sure enough they're yours."  --Richard Bach


More information about the Python-Dev mailing list