On Mon, Nov 12, 2018 at 11:23:21AM -0500, David Mertz wrote: > >>> import pandas as pd > >>> import numpy as np > >>> I = pd.IndexSlice > >>> J = np.s_ > >>> I[4:10:3] > slice(4, 10, 3)
I'm not entirely sure that I like the idea of conflating slice *constructor* with slice *usage*. Slice objects are objects, like any other, and I'm not convinced that overloading slice syntax to create slice objects is a good design. I'm pretty sure it would have confused the hell out of me as a beginner to learn that mylist[1::2] took a slice and [1::2] make a slice. But at least numpy and pandas has the virtual of needing a prefix to make it work. > You don't get your range-like behavior with those, but it's easy to > construct. I'm having a think-o. I think it should be possible to make a > RangeSlice class that will act like an enhanced version of pd.IndexSlice, > but my try was wrong. Just because we can do something, doesn't mean we should. -- Steve _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/