> > Because > > >>> dict(foo=:1) > File "<string>", line 1 > dict(foo=:1) > ^ > SyntaxError: invalid syntax >
I don't see how that's an argument, we are talking about a syntax extension. Slice builder syntax is only every allowed in a subscript. Edit my original grammar change proposal to: ``` subscriptlist: ... | kwargsubscript (',' kwargsubscript )* [','] kwargsubscript: NAME '=' subscript ``` Now slices are allowed in keyword arguments. -- Caleb Donovick On Tue, Oct 8, 2019 at 1:09 PM Anders Hovmöller <bo...@killingar.net> wrote: > > > On 8 Oct 2019, at 18:59, Todd <toddr...@gmail.com> wrote: > > > > > On Tue, Oct 8, 2019, 12:46 Anders Hovmöller <bo...@killingar.net> wrote: > >> >> >> On 8 Oct 2019, at 18:35, Todd <toddr...@gmail.com> wrote: >> >> On Tue, Oct 8, 2019 at 12:22 PM Andrew Barnert via Python-ideas < >> python-ideas@python.org> wrote: >> >>> On Oct 7, 2019, at 21:21, Caleb Donovick <donov...@cs.stanford.edu> >>> wrote: >>> > >>> > > But what if you wanted to take both positional AND keyword? >>> > >>> > I was suggesting that that wouldn't be allowed. So subscript either >>> has a single argument, a tuple of arguments, or a dictionary of arguments. >>> Allowing both has some advantages but is less cleanly integratible. >>> >>> The problem is that half the examples people conjure up involve both: >>> using the keywords as options, while using the positional arguments for the >>> actual indices. Calling the proposal “kwargs in getitem” encourages that >>> thinking, because that’s the prototypical reason for kwargs in function >>> calls. >>> >>> If there were non-toy examples, so people didn’t have to imagine how it >>> would be used for themselves, that might be helpful. >>> >>> >> Here is an example modified from the xarray documentation, where you want >> to assign to a subset of your array: >> >> da.isel(space=0, time=slice(None, 2))[...] = spam >> >> With this syntax this could be changed to: >> >> da[space=0, time=:2] = spam >> >> >> I must have missed something... when did the proposal we're discussing >> start allowing : there? >> >> / Anders >> > > Why wouldn't it? > > > Because > > >>> dict(foo=:1) > File "<string>", line 1 > dict(foo=:1) > ^ > SyntaxError: invalid syntax > > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@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/ZJDP2H7EVGOFDVAE4ZYLUMKNNZN6UFCR/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@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/2PUTYEP3XO7U7BJNNZZHICV7RQZNTLV2/ Code of Conduct: http://python.org/psf/codeofconduct/