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

Stephen J. Turnbull stephen at xemacs.org
Tue Jun 25 17:03:42 CEST 2013


Greg Ewing writes:
 > 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,

Which are?  If you've already explained them, or somebody else has, at
least hint, please.  I can abstractly imagine the kind of thing you're
talking about, but I've never experienced a case where "foo(bar=bar)"
bothered me because the identity of the object named was so strong as
to offend my sensibility when writing the name twice.

 > it's no accident that the two names are spelled the same, because
 > conceptually they represent the very same thing.

In such a case, I would almost certainly design the API (one or the
other) to enable passing this name (that really lives in a super-
namespace) as a positional argument.

Or (as the OP posited, though you haven't) in a case where I have a
bunch of such "no accident" variable names, I'd spend some time
thinking about whether I should factor out a class here so I could
pass a single "no accident" object name (preferably positionally).

Bottom line, I still have trouble with the idea that this is a big
enough problem to deserve a syntactic solution.



More information about the Python-ideas mailing list