[Python-ideas] Short form for keyword arguments and dicts

Nick Coghlan ncoghlan at gmail.com
Thu Jun 27 15:27:18 CEST 2013


On 27 June 2013 23:05, Joshua Landau <joshua.landau.ws at gmail.com> wrote:
> I... don't understand. Did you perhaps misread my post?

Sorry, I should have been clearer - I was agreeing with you :)

Ethan had indicated that he saw the use of a bare "*" to introduce
keyword only argument parameter declarations as some magic new syntax
unrelated to tuple packing. It isn't - it's still a tuple packing
declaration like "*args", it's just one *without a named destination*,
so we can put more stuff after it in the parameter list without
allowing an arbitrary number of positional arguments. The other places
where we allow tuple packing in a binding target are positional only,
so there's no need for such a notation.

It's certainly one of the more obscure aspects of Python's syntax, but
there's still an underlying logic to it. (PEP 3102 has the details,
but be aware that PEP uses the word "argument" in a few places where
it should say "parameter" - PEP 362 better covers the differences,
although a useful shorthand is "as part of a function call, parameter
names are bound to argument values")

Cheers,
Nick.

--
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list