[Python-Dev] PEP 3102: Keyword-only arguments
Edward Loper
edloper at gradient.cis.upenn.edu
Mon May 1 04:50:49 CEST 2006
Terry Reedy wrote:
> There are two subproposals: first, keyword-only args after a variable
> number of positional args, which requires allowing keyword parameter
> specifications after the *args parameter, and second, keyword-only args
> after a fixed number number of positional args, implemented with a naked
> '*'. To the first, I said "The rationale for this is pretty obvious.". To
> the second, I asked, and still ask, "Why?".
I see two possible reasons:
- A function's author believes that calls to the function will be
easier to read if certain parameters are passed by name, rather
than positionally; and they want to enforce that calling
convention on their users. This seems to me to go against the
"consenting adults" principle.
- A function's author believes they might change the signature in the
future to accept new positional arguments, and they will want to put
them before the args that they declare keyword-only.
Both of these motivations seem fairly weak. Certainly, neither seems to
warrant a significant change to function definition syntax.
But perhaps there are other use cases that I'm failing to consider.
Anyone know of any?
-Edward
More information about the Python-Dev
mailing list