On 2/09/20 2:24 am, Steven D'Aprano wrote:
On Sun, Aug 30, 2020 at 05:49:50PM +1200, Greg Ewing wrote:
On 30/08/20 3:06 pm, Steven D'Aprano wrote:
On Thu, Aug 27, 2020 at 11:13:38PM +1200, Greg Ewing wrote:
a[17, 42]
a[time = 17, money = 42]
a[money = 42, time = 17]
>
Compares to the majority of realistic examples given in this discussion
and the PEP, your example doesn't look to me like an item or key lookup.
It looks more like a function call of some sort.
I know that, in a sense, subscript lookups are like function calls, and
I also acknowledge that I don't know your intended semantics of that
example.
It was a reference to earlier discussions of pandas and xarray, where
there is a notion of axes having names, and a desire to be able to
specify index values by name, for the same reasons that we sometimes
want to specify function arguments by name.
It's true that you can't tell just by looking at an indexing expression
what the semantics of the keywords are, but the same is true of function
calls. We rely on contextual knowledge about what the function does in
order to interpret the keywords.
Likewise here. If you know from context that a is an array-like object
with axes named 'time' and 'money', then I think the meaning of the
indexing expression will be quite clear. I also think that it's
something people will naturally expect to be able to use index keywords
for -- to the point that if they can't, their reaction will be
"Why the flipping heck not?"
Which is why I was somewhat perplexed when it was suggested that we
should discount this use case purely because it wasn't cited in the
original proposal (which turned out to be wrong anyway).
--
Greg
_______________________________________________
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/Z2GOU65V2EU27FVQDFF3EJUZRGOIS6TD/
Code of Conduct: http://python.org/psf/codeofconduct/