That would be even more direct....but it require syntax support, usefull mainly for people doing multdim complex slicing (i.e numpy users). I may be wrong, but I do not see it gain much support outside numpy...

slice[....] is probably much more easy to swallow for standard python users, and almost as good imho.
It reuse getitem, so it imply the produced slice will behaves exactly like it would if it was not stored/reused, and almost garantee it will be the case indeed (even if the slice syntax is extended)

Getting this to work including a new module would be nice. Eventually, having it standard is positive too, it means slice manipulation will become more standardised.

On Monday, July 23, 2018 at 12:32:04 PM UTC+2, Jeroen Demeyer wrote:
On 2018-07-23 12:24, Jeroen Demeyer wrote:
> Another solution that nobody has mentioned (as far as I know) is to add
> additional syntax to the language for that. For example, one could say
> that (1:3) could be used to construct slice(1, 3) directly. The
> parentheses are required to avoid confusion with type hints. I'm not a
> Python language expert, but I don't think that type hints can occur
> inside parentheses like that.

And this could be extended to tuples (1:3, 2:4) and lists [1:3, 2:4] of
slices too.
Python-ideas mailing list
Code of Conduct: