[issue42352] A string representation of slice objects with colon syntax

2020-11-20 Thread Terry J. Reedy
Terry J. Reedy added the comment: What you are or should be asking for is an alternate string representation method, perhaps called 'colon', so that for instance myslice.colon() == '::2' The function could take an optional length (as with .indices, but optional) to produce the same numbers

[issue42352] A string representation of slice objects with colon syntax

2020-11-13 Thread Ross Barnowski
New submission from Ross Barnowski : It would be nice if there were a way to get a string representation of a slice object in extended indexing syntax, e.g. ``` >>> myslice = slice(None, None, 2) >>> print(myslice) '::2' ``` One motivating use-case is in descriptive error messages, e.g. ```