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

Ron Adam ron3200 at gmail.com
Tue Jun 25 21:37:46 CEST 2013



On 06/25/2013 03:15 AM, Greg Ewing wrote:
> Stephen J. Turnbull wrote:
>> Ah, but here we have the case of two *different* names that are
>> spelled the same[1], and what Steven is pointing out is that for this
>> syntax to work, these different names that are spelled the same must
>> stay in sync.
>
> I dispute that they're different names. In the use cases
> I have in mind, it's no accident that the two names are
> spelled the same, because conceptually they represent the
> very same thing. Giving them different names would be
> confusing and probably indicate an error.
>
> If the names were only accidentally the same, I would
> probably want to rename one of them to avoid giving the
> misleading impression that they were related.


I think some of the misunderstandings.. might be weather or not we are 
talking about function definitions or function calls, and/or other blocks 
that might be reused in different locations.

If a function definitions were to set the calling syntax, then yes, it 
would be an issue because it would force the use of a particular name at 
all the call sites.  But I don't think that is what is being proposed.

But if 'name=' was just syntactic sugar for 'name=name', then it really 
wouldn't make any difference.  Just use it at any call sight in place of a 
keyword argument pair that is alike.  The compiler would just generate the 
same code as if you did use the full 'name=name' notation.  And all the 
same rules would apply.

But I'm still -1

It looks too much like a pass by reference to me, which python doesn't 
currently do.  And I don't like the '=' with nothing on the right.

The 'spam=spam' pair that is being discussed is binding an object bound to 
the spam on the right to a new name in a new location.  I think the shorter 
syntax will make that harder to see and understand for new users.

What the notation is really doing is..

    future_local name = name

I can't think of a good alternative syntax for that, that which is as clear 
as 'f(spam=spam)'.


But I do find these discussions interesting because they can stimulate new 
ideas I otherwise wouldn't think of.

Cheers,
     Ron








More information about the Python-ideas mailing list