[Python-ideas] slice.literal notation
Nick Coghlan
ncoghlan at gmail.com
Fri Jun 12 08:53:42 CEST 2015
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.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list