On Tue, Aug 4, 2020 at 4:38 AM Todd firstname.lastname@example.org wrote:
One potential issue with this approach just occurred to me. I apologise if my thinking on this is wrong.
Say a project implements __getitem__ with the signature
__getitem__(self, index, **kwargs)
Doesn't that mean that a "index" will not be an allowable index label, and that this conflict will depend on knowing the particular implementation details of the dunder methods?
Yes, that would be correct. However, the function could instead be defined as:
def __getitem__(self, index, /, **kwargs): ...
and then there'd be no conflict (as "self" and "index" must be passed positionally). In effect, the naive spelling (which permits self and index to be passed as keywords) would be a subtle bug that could easily be corrected.