[Python-Dev] PEP 3102: Keyword-only arguments (original) (raw)
Edward Loper edloper at gradient.cis.upenn.edu
Mon May 1 14:36:03 CEST 2006
- Previous message: [Python-Dev] PEP 3102: Keyword-only arguments
- Next message: [Python-Dev] PEP 3102: Keyword-only arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Martin v. Löwis wrote:
One reason I see is to have keyword-only functions, i.e. with no positional arguments at all:
def makeperson(*, name, age, phone, location): pass which also works for methods: def makeperson(self, *, name, age, phone, location): pass In these cases, you don't want name, age to be passed in a positional way. How else would you formulate that if this syntax wasn't available?
But is it necessary to syntactically enforce that the arguments be used as keywords? I.e., why not just document that the arguments should be used as keyword arguments, and leave it at that. If users insist on using them positionally, then their code will be less readable, and might break if you decide to change the order of the parameters, but we're all consenting adults. (And if you do believe that the parameters should all be passed as keywords, then I don't see any reason why you'd ever be motivated to change their order.)
-Edward
- Previous message: [Python-Dev] PEP 3102: Keyword-only arguments
- Next message: [Python-Dev] PEP 3102: Keyword-only arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]