On Sat, Aug 15, 2020 at 8:02 PM Todd firstname.lastname@example.org wrote:
On Sat, Aug 15, 2020 at 7:26 PM Stefano Borini email@example.com wrote:
QUESTION Suppose we have >>> d[x=1, y=2] = 42 >>> d[x=1, y=2] 42 where d is an instance of a suitable class X that has no special
knowledge of keywords.
Initially, when I wrote the pep, the idea was that there was no distinction of kwargs and normal args. Basically the idea was that currently the only "metainfo" associated to every argument is purely positional (e.g. the meaning of position 1 is implicit). But index 1 can have a specific semantic meaning (e.g. it could be a day). So in practice they would be one and the same, just that you add non-positional semantic meaning to indexes, and you can refer to them either through the position, or this additional semantic meaning.
In other words, if you claim that the first index is day, and the second index is detector, somehow, there is no difference between these
d[3, 4] d[day=3, detector=4] d[detector=4, day=3]
In fact, my initial feeling would be that you can use either one or the other. You should not be able to mix and match.
the pep went through various revisions, and we came to a possible proposal, but it's not set in stone.
This would definitely not be sufficient for xarray, which I see as being one of the main users of this syntax. The whole point is to be able to specify an arbitrary subset labeled dimensions.
Are you saying that for xarray it is important to distinguish between `d[day=3, detector=4]` and `d[detector=4, day=3]`? If we just passed the keyword args to `__getitem__` as an extra `**kwds` argument (which preserves order, since Python 3.6 at least), that should work, right? If not, can you clarify?