On Tue, Aug 4, 2020 at 4:38 AM Todd <toddr...@gmail.com> 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.

ChrisA
_______________________________________________
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/YHPWH6FGSKASDXI5AQN7JE5J6B5A2BZ5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to