[Python-Dev] PEP 3102: Keyword-only arguments
Terry Reedy
tjreedy at udel.edu
Sun Apr 30 05:30:38 CEST 2006
"Talin" <talin at acm.org> wrote in message news:4453B025.3080100 at acm.org...
>
> def sortwords(*wordlist, case_sensitive=False):
The rationale for this is pretty obvious. But ...
> 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):
> ...
>
> 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?
tjr
More information about the Python-Dev
mailing list