[Python-ideas] slice.literal notation
Joseph Jevnik
joejev at gmail.com
Wed Jun 10 18:23:32 CEST 2015
I am not sure if this makes sense in the ast module only because it does
not generate _ast.Slice objects and instead returns the keys.
On Wed, Jun 10, 2015 at 12:20 PM, Antoine Pitrou <solipsis at pitrou.net>
wrote:
> On Wed, 10 Jun 2015 19:01:49 +0300
> Tal Einat <taleinat at gmail.com> wrote:
> > >
> > >>>> slice.literal[0]
> > > 0
> > >>>> slice.literal[0, 1]
> > > (0, 1)
> > >>>> slice.literal[0, 1:]
> > > (0, slice(1, None, None)
> > >>>> slice.literal[:, ..., ::-1]
> > > (slice(None, None, None), Ellipsis, slice(None, None, -1)
> > >
> > > These examples show that sometimes the subscript notation is much more
> clear
> > > that the non-subscript notation.
>
> Agreed.
>
> > > I believe that while this is trivial, it is very convinient to have on
> the
> > > slice type itself so that it is quickly available. This also prevents
> > > everyone from rolling their own version that is accesible in different
> ways
> > > (think Py_RETURN_NONE).
> > > Another reason that chose this aproach is that it requires no change
> to the
> > > syntax to support.
> >
> > In regard with the first suggestion, this has already been mentioned
> > on the tracker but is important enough to repeat here: This already
> > exists in NumPy as IndexExpression, used via numpy.S_ or
> > numpy.index_exp.
>
> Probably, but it looks useful to enough to integrate the standard
> library.
> Another possible place for it would be the ast module.
>
> Regards
>
> Antoine.
>
>
> _______________________________________________
> 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/20150610/e2e3a6cc/attachment.html>
More information about the Python-ideas
mailing list