
On Thu, Apr 16, 2020 at 09:21:05PM -0700, Andrew Barnert via Python-ideas wrote:
But I don’t see why that rules out the “bare colon” form that I and someone else apparently both proposed in separate sub threads of this thread:
{ :a, "b": x, :c }
as shorthand for:
{ "a": a, "b": x, "c": c }
I did a double-take reading that, because I visually parsed it as: { :a, "b": x, :c } and couldn't work out what was going on. After saving this draft, closing the email, then reopening it, I read the proposed dict the same way. So I don't think it was just a momentary glitch. I think that, as little as I like the original proposal and am not really convinced it is necessary, I think that it is better to have the explicit token (the key/parameter name) on the left, and the implicit token (blank) on the right: key= I suspect it may be because we read left-to-right in English and Python, so having the implicit blank come first is mentally like running into a pothole at high speed :-) Perhaps those who read right-to-left languages may have fewer problems with it. Or maybe it's just me.
There’s no problem for the parser. Make a trivial change to the grammar to add a `":" identifier` alternative to dict display items, and nothing becomes ambiguous.
Except to the human reader, which is the only ambiguity that *really* matter when you get down to it. If human readers are going to parse it differently from your intention, as I did, then this is going to hurt readability far in excess of the benefit in saving a few characters typed. -- Steven