This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients Arfrever, abarry, josh.r, levkivskyi, llllllllll, mark.dickinson, martin.panter, python-dev, r.david.murray, rhettinger, serhiy.storchaka, steven.daprano, taleinat, yselivanov
Date 2016-11-12.13:48:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
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]


    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:


I had completely forgotten about this feature request, but 
coincidentally re-suggested it on the Python-Ideas mailing 
list earlier today:

The downside is that beginners who are still learning Python's 
syntax may try writing:


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.)
Date User Action Args
2016-11-12 13:48:13steven.dapranosetrecipients: + steven.daprano, rhettinger, mark.dickinson, taleinat, Arfrever, r.david.murray, python-dev, martin.panter, serhiy.storchaka, yselivanov, josh.r, llllllllll, levkivskyi, abarry
2016-11-12 13:48:13steven.dapranolinkissue24379 messages
2016-11-12 13:48:12steven.dapranocreate