On Thu, Aug 27, 2020 at 07:24:01AM -0400, Ricky Teachey wrote: > It kills at least 3 birds with one stone: > > 1. Brings kwd arguments to item dunders (PEP 472 does this too, but a > key/index translation dunder kills two other birds)
I would put it another way: your proposal to redesign subscripting is independent of whether or not keyword subscripts are permitted. We could redesign the comma-separated item part of it without introducing keywords at all. There is nothing in your proposal that requires keywords. Just delete the bits about `**kwargs` and the rest of it stands as it is. PEP 472, on the other hand, is *all about keywords*. Keywords are irrelevant to your proposal to redesign subscripting. We could take it with or without keywords. > 2. Switches positional arguments over to the function paradigm, bringing > the full power of python signature parsing to subscripting. If you want a function call, use function call syntax. PEP 472 is about adding keyword support to subscripting. The aim of the PEP is still for subscripting to fundamentally be about an index or key, not about making square brackets to be a second way to do function calls. I'll have more to say about that later. > 3. Removes the need to write calls to the same supporting function in the > item dunders. They are called automatically. I don't understand that sentence. [...] > My current attempt is this: > > def __subscript__(self, *args, **kwargs) -> Tuple [Tuple[Any], Dict[str, > Any]]: > return t NameError: name 't' is not defined > Which, for a getitem dunder call, `t` becomes: > > obj.__getitem__(*t[0], **t[1]) What does this mean? You assign t = obj.__getitem__(*t[0], **t[1]) and then return t? -- Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/KJZHRMRVZMY6CBHBKSWTWCINQYHHZ4IY/ Code of Conduct: http://python.org/psf/codeofconduct/