On Fri, Aug 14, 2020 at 08:45:44AM -0400, Ricky Teachey wrote:
It seems very obvious to me that kwd args only should be valid, as Greg Ewing said, if kwd args are added.
Absolutely. We shouldn't even need to debate this. Would we consider a language change that forced every single function to accept arbitrary keyword-only arguments whether they made sense to the function or not?
Of course we would not. So why are we even considering a language change to force every single subscriptable object to accept arbitrary keyword-only arguments unless the maintainer changes their class to explicitly reject them?
If you want to use an arbitrary bunch of key:value pairs as a dict key, you should bundle them into a frozen dict or frozen SimpleNamespace object, and pass that as your key.
(I would support the addition of either or both of those frozen types to the standard library.)
I'm less sure about no arguments, but perhaps.
In mathematics notation, subscripts can be values, or they can be descriptions, and sometimes a combination of the two. For example:
x[i] x[i even]
(Excuse the lack of WYSIWYG display, I'm limited to plain unformatted text here, but I trust the intention is obvious.)
Python subscripting supports the first version, but not the second. Allowing keyword args would go some way to rectifying that, see PEP 472 for motivation and use-cases.
But with *no subscript at all*, you just have x. Unlike function calls with no arguments, I maintain that `x[]` is meaningless that, in practice, would only be a error. Either a coding error or a conceptual error. That should remain an error.