[Python-ideas] slice.literal notation
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>
> On Wed, 10 Jun 2015 19:01:49 +0300
> Tal Einat <taleinat at gmail.com> wrote:
> > >
> > >>>> slice.literal
> > > 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
> > > that the non-subscript notation.
> > > I believe that while this is trivial, it is very convinient to have on
> > > slice type itself so that it is quickly available. This also prevents
> > > everyone from rolling their own version that is accesible in different
> > > (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
> Another possible place for it would be the ast module.
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas