Slice 'size' parameter (in the style of pairwise)

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:
In the case where the list is not evenly divisible by the provided parameters, I think for [] notation a guarantee that each item in the returned iterator will have len(item) == size is appropriate, rather than returning all the data even if len(item) < size; slice() could have enhanced parameters over and above [] notation that could allow for returning "deficient" items. A negative value size parameter could also be possible:
Thoughts? < Flash forward to 200 years from now. >
a_list[::::7:::::::::::::-1::] (42, 'of course!')

On 02Jun2022 19:26, Kevin <msftftw@hotmail.com> 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.
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.
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 <cs@cskk.id.au>

On 02Jun2022 19:26, Kevin <msftftw@hotmail.com> 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.
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.
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 <cs@cskk.id.au>
participants (2)
-
Cameron Simpson
-
Kevin