[Python-ideas] PEP pre-draft: Support for indexing with keyword arguments

Tim Delaney timothy.c.delaney at gmail.com
Fri Jul 4 22:46:58 CEST 2014


On 5 July 2014 06:39, Nathaniel Smith <njs at pobox.com> wrote:

> On Fri, Jul 4, 2014 at 9:10 PM, Tim Delaney <timothy.c.delaney at gmail.com>
> wrote:
> > 1. I think you absolutely *must* address the option of purely syntactic
> > sugar in the PEP. It will come up on python-dev, so address it now.
> >
> >     a[b, c=f, e=f:g:h]
> >     -> a[b, 'c':d, 'e':slice(f, g, h)]
> >
> > The rationale is readability and being both backwards and forwards
> > compatible - existing __getitem__ designed to abuse slices will continue
> to
> > work, and __getitem__ designed to work with the new syntax will work by
> > abusing slices in older versions of Python.
>


> pandas from using this feature. In pandas, slices like foo["a":"b"]
> already have a meaning (i.e., take all items from the one labeled "a"
> to the one labeled "b").
>

If that's the case then it should be listed as a reason in the PEP for a
change larger than syntax sugar, otherwise this important information will
be lost.

One of the first suggestions when this PEP came up was to just (ab)use
slices - people will use the syntax they have available to them.

Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140705/8cec56e8/attachment.html>


More information about the Python-ideas mailing list