On Mon, Jul 23, 2018 at 4:37 PM David Mertz <me...@gnosis.cx> wrote:

> I find pandas.IndexSlice makes a lot of operations easier to spell. As
> simple as it is, it's a valuable capability. Rather than every library—or a
> number of them anyway—creating the same 4 lines of code with a different
> name, it would be much nicer to have it as a class __getitem__ method, e.g.
> slice[...], or as an attribute of the slice object, such as
> slice.literal[...].
>

I'd really like to move this proposal forward in some form.

There have been three basic proposals for where to put the __getitem__
based constructor:
1. slice: slice[...] potentially conflicts with typing syntax.
2. slice.literal: This is potentially confusing, because in many cases it
does not actually create a single slice object.
3. operator.subscript: This is the last proposal standing, and was also the
outcome of the previous discussion on python-ideas:
https://mail.python.org/pipermail/python-ideas/2015-June/034086.html

I think the repeated interest in this topic demonstrates that there are
real use cases for operator.subscript, even though it would be slightly
less accessible than putting it directly on slice or slice.literal.

As a next step, would it be helpful to summarize the use cases and
reasoning in a PEP?
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to