Hi Greg

Thank you, for your support for d[x=1, y=2] being valid syntax.

You ask if I have any use cases in mind for a general keyword key class being part of standard Python. Good question.

Anyone who is experimenting with keyword keys would, I think, appreciate having something they can use straight away. Thus, I think, any use case for PEP 472 is also a use case for the general keyword class I'm suggesting. No use cases for PEP 472 would of course be fatal.

Storing function call results would be a use case. For this, look at the implementation of functools.lru_cache.

I am keen to develop, with others, examples of how PEP 472 could help us in real-world programming. Even if convinced that PEP 472 is a good idea, the examples would help us get the details right, and also help with formal and informal documentation.

For a specific example, a simple ad hoc way of recording data. For example
    >>> height[x=10, y=14] = 2010

We can already use dictionaries in this way, as in
    >>> height[10, 14] = 2010

So this is a bit like using named tuples instead of tuples.

I think that's enough for now.

-- 
Jonathan

On Fri, Aug 14, 2020 at 12:28 PM Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
On 14/08/20 10:03 pm, Jonathan Fine wrote:
> NO POSITIONAL ARGUMENTS
> I'd like
>      >>> d[x=1, y=2]
> to be valid syntax. It's not clear to me that all agree with this.

If keywords are to be allowed, it seems reasonable to me
that this should be legal.

>      >>> d[x=1, y=2] = 42
>      >>> d[x=1, y=2]
>      42
>      >>> d[a='alpha', g='gamma', z=12] = 'cheese'
>      >>> d[a='alpha', g='gamma', z=12]
>      'cheese'
>
> My question is this: Should such a class ... be part of standard Python,

Do you have any use cases in mind for this?

To justify being built in, it would need to have a wide range
of uses.

--
Greg