[Python-ideas] slice[] to get more complex slices

Todd toddrjen at gmail.com
Mon Jul 23 08:13:48 EDT 2018


On Mon, Jul 23, 2018 at 6:24 AM, Jeroen Demeyer <J.Demeyer at ugent.be> wrote:

> On 2018-07-23 11:58, Grégory Lielens wrote:
>
>> Not sure slice[1::3] can be done
>>
>
> It can be done. Since "slice" is a class, it would require a metaclass
> though.
>
> 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.
>
>
If I remember correctly Guido explicitly rejected requests for such
syntax.  This proposal was intended as a compromise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180723/4ff08766/attachment.html>


More information about the Python-ideas mailing list