On Thu, Aug 20, 2020 at 05:57 Random832 <random...@fastmail.com> wrote:

>
> I have an implementation proposal that I believe is distinct from any of
> the ones mentioned in the PEP currently.
>
>
>
> Pass keyword arguments as ordinary keyword arguments [which any particular
> __getitem__ implementation is free to handle as **kwargs, specific
> keywords, or simple named arguments]. When a single positional argument is
> passed, it's used directly; when zero or two or more are passed, they are
> bundled into a tuple and passed as a single positional argument. Having
> zero arguments result in an empty tuple allows for easy conceptual
> compatibility with numpy.
>
>
>
> d[]: d.__getitem__(())
>
> d[0] : d.__getitem__(0)
>
> d[0,1] : d.__getitem__((0, 1))
>
> d[x=0]: d.__getitem__((), x=0)
>
> d[0, y=1]: d.__getitem__(0, y=1)
>
> d[0, 1, z=2]: d.__getitem__((0, 1), z=2)


That may not be in the PEP, but apart from the edge cases for d[] and
d[x=0] it’s exactly what I and Steven have been proposing for quite a while.

—Guido
-- 
--Guido (mobile)
_______________________________________________
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/GUQNS2AXY5NWEOGHTTX2T6W2WI3HQQE4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to