On Fri, Jul 17, 2020 at 9:22 PM Ricky Teachey <ri...@teachey.org> wrote:

> >>> # The positional arguments aren't part of the KeyObject
> >>> d[a, b:c, d, e=5, f=6] == d.__getitem__((a, b:c, d), KeyObject(e=5,
> f=6))
>
> This raises a question that needs to be answered, then: what would be the
> utility of mixing together positional and kwd arguments in this way?
>
> Even the xarray examples given so far don't seem to make use of this
> mixture. From my knowledge of pandas I am not sure what the meaning of
> this would be, either.
>

One use case that comes up in xarray and pandas is support for indicating
indexing "modes". For example, when indexing with floating point numbers
it's convenient to be able to opt-in to approximate indexing, e.g.,
something like:
array.loc[longitude, latitude, method='nearest', tolerance=0.001]

(This use case is actually already mentioned in PEP 472, as "an optional
contextual to the indexing":
https://www.python.org/dev/peps/pep-0472/#use-cases)
_______________________________________________
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/XC6XYIUHDYFR43CEV3QR67JK7UALYACL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to