[Python-ideas] slice.literal notation

Joseph Jevnik joejev at gmail.com
Fri Jun 12 22:45:33 CEST 2015


I can update my patch to move it to the operator module
On Jun 12, 2015 9:28 AM, "Tal Einat" <taleinat at gmail.com> wrote:

> On Fri, Jun 12, 2015 at 10:41 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> > 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.
>
> It looks good to me as well.
>
> +1 for adding this as described and naming it operator.subscript.
>
> - Tal Einat
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150612/12713085/attachment.html>


More information about the Python-ideas mailing list