On Sun, Aug 23, 2020 at 09:43:14PM -0700, Christopher Barker wrote:
> Why not allow slice syntax as an expression everywhere? Everywhere I’ve
> tried, it’s a syntax error now, but is there any technical reason that it
> couldn’t be used pretty much anywhere?
When do you use slices outside of a subscript?
More importantly, when do you need slices outside of a subscript where
they would benefit from being written in compact slice syntax rather
than function call syntax?
I think I've done something like this once or twice:
chunk = slice(a, b, step)
for seq in sequences:
do_something_with(seq[chunk])
but I don't even remember why :-)
I'm not convinced that the first line would be better written as:
chunk = a:b:step
But this definitely wouldn't be:
chunk = ::
So apart from "but it looks cool" why do you want this?
(I agree that slices look cool inside subscripts, I'm just not so sure
about outside of them.)
--
Steve
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/WRD3S6TSHFFJOWNBA7ZZ7W5RKXSZQYF3/
Code of Conduct: http://python.org/psf/codeofconduct/