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

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Jun 25 02:40:34 CEST 2013


Steven D'Aprano wrote:
> If you refactor the name "ham" to "spam" in
> 
> func(=ham, eggs=SCRAMBLED, toast=None, coffee='white')
> 
> you also need to change the implicit keyword syntax back to ordinary 
> explicit keyword syntax, or it will break.

I don't see that as a major problem. If you change the name
of a keyword argument, you have to review all the places it's
used anyway.

 > I cannot think of any other feature, in any other language,
> where changing a variable's name requires you to change the syntax you 
> can use on it.

That can happen already. If you're accepting a ** argument
and passing it on, and the names change in such a way that
the incoming and outgoing names no longer match, that whole
strategy will stop working. The change required in that case
is much bigger than just replacing '=foo' with 'foo=blarg'.

> We shouldn't want keyword arguments *everywhere*, but only where 
 > they add clarity rather than mere verbosity.

I agree that wanting to using keyword arguments everywhere
is excessive. But I do sympathise with the desire to improve
DRY in this area. While the actual number of occasions I've
encountered this sort of thing mightn't be very high, they
stick in my mind as being particularly annoying.

-- 
Greg


More information about the Python-ideas mailing list