I think it is worth directly discussing the availability of slices in PEP
472-style keyword indices, since we seem to have mostly converged on a
dunder method signature.  This is an issue that has been alluded to
regarding keyword-based (labelled) indices but not directly addressed.  The
basic syntax would be something like d[x=1:3].

I am strongly in favor of having slices.  The main motivating factor for
me, labelled dimensions in xarray, would be much, much less useful without
support for slices.  In fact, as PEP 472 currently mentions, the big
benefit of indexing over method calls is that indexing supports slice
syntax while method calls don't.

In a more general sense, I feel not allowing slices would create an
artificial distinction between labelled and positional indices that I don't
think is justified.  They would work the same, except for slices where
labelled indices behave differently.  It would be a strange gotcha.

So I think any revision to PEP 472 or new PEP should directly and
explicitly support the use of slices.
_______________________________________________
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/TOABKD7A5X653BTTU3MZICWURNGPMY47/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to