
On Nov 12, 2016 5:46 PM, "David Mertz" <mertz@gnosis.cx> wrote:
If we *do* want the name 'slice' as the spelling for the thing that can
either be called or indexed to create a slice object, we could probably use some boilerplate like this:
In [1]: class Slice: ...: def __init__(self): ...: self.slice = slice ...: def __getitem__(self, x): ...: return x ...: def __call__(self, *args, **kws): ...: return self.slice(*args, **kws) ...:
In [2]: slice = Slice()
In [3]: slice(1,10,2) Out[3]: slice(1, 10, 2)
In [4]: slice[1:10:2] Out[4]: slice(1, 10, 2)
I'm sure there are some less common uses of the name 'slice' that would
break here. That's why I'd want an official standard behavior. isinstance(obj, slice) would be a notable one. -n