[Python-ideas] slice.literal notation
Terry Reedy
tjreedy at udel.edu
Fri Jun 12 09:41:55 CEST 2015
On 6/12/2015 2:53 AM, Nick Coghlan wrote:
> On 11 June 2015 at 22:57, Tal Einat <taleinat at gmail.com> wrote:
>>
>> I actually think "subscript" is quite good a name. It makes the
>> explicit distinction between subscripts, indexes and slices.
>
> Yeah, I've warmed to it myself:
>
> zero = operator.subscript[0]
>
> ellipsis = operator.subscript[...]
>
> reverse = slice(None, None, -1)
> reverse = operator.subscript[::-1]
>
> all_rows_first_col = slice(None), slice(0)
> all_rows_first_col = operator.subscript[:, 0]
>
> first_row_all_cols_but_last = slice(0), slice(None, -1)
> first_row_all_cols_but_last = operator.subscript[0, :-1]
>
> I realised the essential problem with using "item" in the name is that
> the "item" in the method names refers to the *result*, not to the
> input. Since the unifying term for the different kinds of input is
> indeed "subscript" (covering indices, slices, multi-dimensional
> slices, key lookups, content addressable data structures, etc), it
> makes sense to just use it rather than inventing something new.
If the feature is added, this looks pretty good to me.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list