[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-27 Thread Chris Angelico
On Mon, Sep 28, 2020 at 3:33 PM Christopher Barker wrote: > As for using an empty tuple, thanks Guido for laying out the logic so > succinctly, and it does make it pretty simple that only the one index case is > special. Nevertheless, I think most folks expect the special case to be at > the en

[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-27 Thread Christopher Barker
On Sun, Sep 27, 2020 at 1:51 PM David Mertz wrote: > On Sun, Sep 27, 2020 at 10:41 AM Stefano Borini > wrote: > >> I kept the tuple as the accepted option, but I am personally open to >> NoIndex as well. I am not sure how the SC would take a non-hashable, new >> constant to be >> honest, for suc

[Python-ideas] Re: PEP 637 - support for indexing with keyword arguments (Was: Re: PEP 9999 (provisional): ...)

2020-09-27 Thread Stephan Hoyer
On Sat, Sep 26, 2020 at 8:40 PM Steven D'Aprano wrote: > On Sat, Sep 26, 2020 at 01:47:56PM -0300, Sebastian Kreft wrote: > > > In this fashion have you considering having keyword only indices, that is > > to only allow either obj[1, 2] or obj[row=1, col=2] (if the class > supports > > it), and d

[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-27 Thread Guido van Rossum
On Sun, Sep 27, 2020 at 4:29 AM Stefano Borini wrote: > ``` > >>> obj[**d] = "foo" # no kwd arguments provided here > ``` > I committed yesterday the following proposal > > https://github.com/python/peps/pull/1622 > > But to be honest I am not sure if we should disallow these two constructs > ``

[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-27 Thread MRAB
On 2020-09-27 21:47, David Mertz wrote: On Sun, Sep 27, 2020 at 10:41 AM Stefano Borini mailto:stefano.bor...@gmail.com>> wrote: I kept the tuple as the accepted option, but I am personally open to NoIndex as well. I am not sure how the SC would take a non-hashable, new constant to

[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-27 Thread David Mertz
On Sun, Sep 27, 2020 at 10:41 AM Stefano Borini wrote: > I kept the tuple as the accepted option, but I am personally open to > NoIndex as well. I am not sure how the SC would take a non-hashable, new > constant to be > honest, for such a specific use case. > My "vote" is for NoIndex. I suggest

[Python-ideas] Adding mixed positional and keyword to PEP 637

2020-09-27 Thread David Mertz
None of the examples posted in use cases show combinations of position and keyword indexing. This feels like an important example, and moreover without it, the discussion of what sentinel to use is less motivated. In discussions, I have mentioned two examples, e.g. distances[4:7, 100:120, 30:

[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-27 Thread Stefano Borini
On Sun, 27 Sep 2020 at 12:28, Stefano Borini wrote: > I am not sure. I am on the fence on many topics. There seem to be no > clear solution on many of them, it boils down to taste and compromise. > In any case, I listen to all proposals (although with a small delay). > I am working on the sentinel

[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-27 Thread Guido van Rossum
On Sat, Sep 26, 2020 at 22:57 Steven D'Aprano wrote: > Christopher, with the greatest respect, it is really demoralising for me > to explain this issue something like three, four, maybe five times now > (I'm not going to go back and count), including this thread which is > specifically about this

[Python-ideas] Re: PEP 637 - support for indexing with keyword arguments (Was: Re: PEP 9999 (provisional): ...)

2020-09-27 Thread Stefano Borini
On Sun, 27 Sep 2020 at 06:27, Steven D'Aprano wrote: > As far as speed and complexity goes, I do not understand the C > implementation well enough to categorically dismiss your claims, but > from everything I have seen, neither is true: this should not have any > significant slowdown, and the incr

[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-27 Thread Stefano Borini
On Sun, 27 Sep 2020 at 05:06, Ricky Teachey wrote: >>> obj[**d] = "foo" # no kwd arguments provided here I committed yesterday the following proposal https://github.com/python/peps/pull/1622 But to be honest I am not sure if we should disallow these two constructs d[*()] d[**{}] as equivale

[Python-ideas] Re: PEP 637 - support for indexing with keyword arguments (Was: Re: PEP 9999 (provisional): ...)

2020-09-27 Thread Sebastian Kreft
On Sun, Sep 27, 2020 at 12:43 AM Steven D'Aprano wrote: > On Sat, Sep 26, 2020 at 01:47:56PM -0300, Sebastian Kreft wrote: > > > In this fashion have you considering having keyword only indices, that is > > to only allow either obj[1, 2] or obj[row=1, col=2] (if the class > supports > > it), and

[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-27 Thread Chris Angelico
On Sun, Sep 27, 2020 at 7:08 PM Steven D'Aprano wrote: > 1. Fill in a default index with one of: > > a. None > b. empty tuple () > c. NotImplemented > d. a new, unhashable builtin Missing or NoIndex > > 1d. avoids any chance of that, but requires a new builtin; > An interesting and very good poin

[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-27 Thread Steven D'Aprano
On Sat, Sep 26, 2020 at 07:12:00PM -0400, Ricky Teachey wrote: > Another inconsistency is that the case of keyword arguments only would bind > the RHS value to the first positional argument, which is the index, and not > the value. I think this is what Guido was referring to when he responded > tal

[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-27 Thread Greg Ewing
On 27/09/20 7:10 pm, Steven D'Aprano wrote: kw = get_keywords() # oops, this returns an empty dict obj[**kw] = value If an explicit d[] is going to be a compile-time error, maybe anything that has the same effect at run time should be an error too? -- Greg __