[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-ideas
Subject:    [Python-ideas] PEP 472 - slices in keyword indices, d[x=1:3]
From:       Todd <toddrjen () gmail ! com>
Date:       2020-08-24 1:40:53
Message-ID: CAFpSVpLWH+xWZ149HCwd8kTsVLZP9xmhSDj41Qu+y5OOczVebA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I think it is worth directly discussing the availability of slices in PEP
472-style keyword indices, since we seem to have mostly converged on a
dunder method signature.  This is an issue that has been alluded to
regarding keyword-based (labelled) indices but not directly addressed.  The
basic syntax would be something like d[x=1:3].

I am strongly in favor of having slices.  The main motivating factor for
me, labelled dimensions in xarray, would be much, much less useful without
support for slices.  In fact, as PEP 472 currently mentions, the big
benefit of indexing over method calls is that indexing supports slice
syntax while method calls don't.

In a more general sense, I feel not allowing slices would create an
artificial distinction between labelled and positional indices that I don't
think is justified.  They would work the same, except for slices where
labelled indices behave differently.  It would be a strange gotcha.

So I think any revision to PEP 472 or new PEP should directly and
explicitly support the use of slices.

[Attachment #5 (text/html)]

<div dir="ltr">I think it is worth directly discussing the availability of slices in PEP 472-style \
keyword indices,  since we seem to have mostly converged on a dunder method signature.   This is an issue \
that has been alluded to regarding keyword-based (labelled) indices but not directly addressed.   The \
basic syntax would be something like d[x=1:3].<div><br></div><div>I am strongly in favor of having \
slices.   The main motivating factor for me, labelled dimensions in xarray, would be much, much less \
useful without support for slices.   In fact, as PEP 472 currently mentions, the big benefit of indexing \
over method calls is that indexing supports slice syntax while method calls \
don&#39;t.</div><div><br></div><div>In a more general sense, I feel not allowing slices would create an \
artificial distinction between labelled and positional indices that I don&#39;t think is justified.   \
They would work the same, except for slices where labelled indices behave differently.   It would be a \
strange gotcha.</div><div><br></div><div>So I think any revision to PEP 472 or new PEP should directly \
and explicitly support the use of slices.</div></div>



_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/TOABKD7A5X653BTTU3MZICWURNGPMY47/
Code of Conduct: http://python.org/psf/codeofconduct/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic