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

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Jun 25 08:47:57 CEST 2013


Steven D'Aprano wrote:
>>The change required in that case
>>is much bigger than just replacing '=foo' with 'foo=blarg'.
> 
> But you don't have to change the *syntax*.

It's still a bigger change than any automated tool will
be able to cope with, and if you're changing it manually,
who cares if the syntax changes or not?

> I cannot think of any other syntax, certainly not in Python, which relies 
> on a name being precisely one value rather than another in order to 
> work.

Pardon? *Every* time you use a name, you're relying on it
being the same as at least one other name somewhere else.

> I exaggerate a little for effect, but it really does seem that many 
> people think that any piece of code, no matter how trivially small, that 
> is repeated is a DRY violation. But that's not what DRY is about.

You seem to think I'm using a form of argument by authority:
"It's DRY, therefore it's undesirable." But that's not what
I'm saying. Rather, I'm saying that I feel it's undesirable,
and I'm using the term DRY to *describe* what I think is
undesirable about it. Maybe I'm not using the term quite the
way it was originally meant, but that has no bearing on how
I feel about the matter and my reasons for it.

> "Every piece of knowledge must have a single, unambiguous, authoritative 
> representation within a system."
> 
> https://en.wikipedia.org/wiki/Don%27t_Repeat_Yourself
> 
> which has nothing to do with writing spam=spam in a function call.

I'm not so sure about that. I've just been watching this:

http://pyvideo.org/video/1676/the-naming-of-ducks-where-dynamic-types-meet-sma

and going by the principles advocated there, if you change the
name of the parameter in the called function, you *should*
change the corresponding parameter of your function to match,
for the sake of consistency. So '=spam' will continue to work
fine after the change. It will also help you to keep your
parameter names consistent by breaking if they're not!

-- 
Greg


More information about the Python-ideas mailing list