<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On 12 November 2016 at 10:26, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
But let's make str() of a slice more suggestive of actual slicing, and<br>
as a bonus, make slices easier to create too.<br>
<br>
str(slice(None, None, None)) => "slice[:]"<br>
<br>
Let the slice type itself be sliceable, as an alternate constuctor:<br>
<br>
slice[:] => returns slice(None)<br>
slice[start:] => returns slice(start, None)<br>
slice[:end] => returns slice(None, end)<br>
slice[start::step] => returns slice(start, None, step)<br>
<br>
and so forth. (This probably would require changing the type of slice to<br>
a new metaclass.)<br>
<br>
And then have str() return the compact slice syntax.<br></blockquote><div><br></div><div>+1, I like this idea, this is very close to what NumPy does.<br></div><div>I would also mention <a href="http://bugs.python.org/issue24379">http://bugs.python.org/issue24379</a><br><br>--<br></div><div>Ivan<br><br></div></div></div></div>