On 02Jun2022 19:26, Kevin  <[email protected]> wrote:
>I might be posting this prematurely, but I had an idea and wanted to float it. 
>Also, I'm new here so hopefully this is appropriate.
>
>How about augmenting slicing with an additional parameter 'size' (name chosen 
>to achieve alliteration; 'start', 'stop', 'step', and 'size'), as such:

[... examples of what it might do ...]

but no examples of why you might want it.

Since this kind of thing is easily done with a range and a generator 
expression:

    a_list[i:i+size] for i in range(start, stop, step)

I don't really see the benefit of yet another potential term in a slice.

>A negative value size parameter could also be possible:
>>>> a_list = [0, 1, 2, 3, 4, 5, 6, 7]
>>>> a_list[:::-2]
>[(1, 0), (2, 1), (3, 2), (4, 3), (5, 4), (6, 5), (7, 6)]

I think it would be better if a negative size removed some arbitrarily 
chosen data from the caller's end in some way, maybe inserting it into 
the list.

>< Flash forward to 200 years from now. >
>>>> a_list[::::7:::::::::::::-1::]
>(42, 'of course!')

Indeed. But there's a reason we ty to avoid letting functions acquire 
many positional parameters. I appreciate that you're illustrating that 
deliberately.

Cheers,
Cameron Simpson <[email protected]>
_______________________________________________
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/33FAD3P4EDKUTRVSMVZHEQY3PPFDNTGQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to