On Thu, Aug 27, 2020 at 1:29 PM David Mertz <me...@gnosis.cx> wrote:

> On Thu, Aug 27, 2020, 1:15 PM Christopher Barker
>
>> I agree -- this is very much a feature for third party packages -- or
>> *maybe* some future stdlib class, but the builtins are fine as they are.
>>
>> In fact, I don't think there's a single use of a tuple of indexes
>> (meaning something other than an arbitrary single object) in the stdlib is
>> there? I know I've only used that in numpy.
>>
>
> I don't know whether it is in the stdlib, but I sometimes use tuples as
> dict keys. E.g.
>
>     mydict[('mertz', 'david')] = 3.1415
>
> Even though I could omit them, I'd almost surely use the parens for that.
> And more likely it would be:
>
>     name = ('mertz', 'david')
>     mydict[name] = 3.1415
>
> Conceptually, an "immutable collection" serves a different purpose than "a
> collection of axes", even if they work then same under the hood.
>

What about something like this:

class Name(NamedTuple):
    first: str
    last: str

d = NamedKeyDict(Named)
d[first='david', last='mertz'] = 1_000_000  # dollars

---
Ricky.

"I've never met a Kentucky man who wasn't either thinking about going home
or actually going home." - Happy Chandler
_______________________________________________
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/42P4KZLB35EFC24HR66U5H3QBN4RK7ST/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to