I'd like to sound out consensus regarding mapping access, where none of the keys are positional. In particular, I suggest that PEP 472 allow syntax and semantics such as >>> d[x=1, y=2] = 42 >>> d[x=1, y=2] 42 and ask whether the class >>> X = type(d) should be part of standard Python.
NO ARGUMENTS At present, item access requires an argument, as a matter of syntax. >>> d SyntaxError: invalid syntax
Compare this to >>> fn() NameError: name 'fn' is not defined
I'd like d to become valid syntax.
SEMANTICS OF NO ARGUMENTS I can see two basic ways of allowing no arguments. One is for the interpreter to construct an object that is the argument passed to __getitem__ and so forth. The other is to not pass an argument at all. I see this as a secondary question.
NO POSITIONAL ARGUMENTS I'd like >>> d[x=1, y=2] to be valid syntax. It's not clear to me that all agree with this. Even if there are no objections, I'd like positive confirmation.
is valid syntax. If so, then there is I think consensus that >>> d[x=1, y=2] = 42 >>> d[x=1, y=2] 42 can be implemented, where d is an instance of a suitable class. Otherwise, what's the point?
QUESTION Suppose we have >>> d[x=1, y=2] = 42 >>> d[x=1, y=2] 42 where d is an instance of a suitable class X that has no special knowledge of keywords.
In other words, we also have for example >>> d[a='alpha', g='gamma', z=12] = 'cheese' >>> d[a='alpha', g='gamma', z=12] 'cheese'
My question is this: Should such a class
X = type(d)
be part of standard Python, as part of PEP 472? (My answer is: Yes, it should be in standard Python.)
At this time, I'm interested in canvassing opinions. Discussion of different opinions perhaps can take place later, or elsewhere. My main concern is to know if there is at present a rough consensus regarding the above.