[Python-Dev] PEP 3102: Keyword-only arguments (original) (raw)

Edward Loper edloper at gradient.cis.upenn.edu
Mon May 1 19:11:54 CEST 2006


Fredrik Lundh wrote:

And again, why would you make me, the user-programmer, type

makeperson(name=namex, age=agex, phone=phonex, location = locationx) #instead of makeperson(namex,agex,phonex,locationx) ? because a good API designer needs to consider more than just the current release.

I believe that it's quite possible that you're right, but I think more concrete answers would be helpful. I.e., how does having parameters that are syntactically keyword-only (as opposed to being simply documented as keyword-only) help you develop an API over time?

I gave some thought to it, and can come up with a few answers. In all cases, assume a user BadUser, who decided to use positional arguments for arguments that you documented as keyword-only.

I think that this kind of concrete use-case provides a better justification for the feature than just saying "it will help API design." As someone who has had a fair amount of experience designing & maintaining APIs over time, perhaps you'd care to contribute some more use cases where you think having syntactically keyword-only arguments would help?

-Edward



More information about the Python-Dev mailing list