23 Jul
2018
23 Jul
'18
3:13 p.m.
On Mon, Jul 23, 2018 at 6:24 AM, Jeroen Demeyer
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.