Steven D'Aprano added the comment: On Sat, Nov 12, 2016 at 08:23:45AM +0000, Raymond Hettinger wrote: > I can't even dream up any scenarios where > ``operator.subscript[3:7:2]`` would be better than > ``slice(3, 7, 2)``.
For that specific example, I completely agree. But I think that in general ``slice[::-1]`` is better than either the current alternative ``slice(None, None, -1)`` or the proposed ``operator.subscript[::-1]``. And there's no comparison once you get to multi-dimensional slices: s = slice[::-1, 1:, 1::2] spam[s] + eggs[s] versus: s = slice(slice(None, None, -1), slice(1, None), slice(1, None, 2)) spam[s] + eggs[s] Even simple examples look nice in slice syntax: slice[3:7:2] I had completely forgotten about this feature request, but coincidentally re-suggested it on the Python-Ideas mailing list earlier today: https://mail.python.org/pipermail/python-ideas/2016-November/043630.html The downside is that beginners who are still learning Python's syntax may try writing: slice(::-1) by mistake. Nevertheless, it seems to me that the advantage to more experienced developers to be able to read and write slice objects using slice format outweighs the temporary confusion to beginners. (I would expect that outside of the Numpy community, few beginners use the slice() object directly, so this would not often affect them.) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24379> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com