FWIW, you can do it with dict already.

o = memo.setdefault(o, o)

On Tue, Dec 3, 2019 at 9:29 AM Soni L. <fakedme...@gmail.com> wrote:
>
> This is an odd request but it'd be nice if, given a set s = {"foo"},
> s["foo"] returned the "foo" object that is actually in the set, or
> KeyError if the object is not present.
>
> Even use-cases where you have different objects whose differences are
> ignored for __eq__ and __hash__ and you want to grab the one from the
> set ignoring their differences would benefit from this.
> _______________________________________________
> 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/T3Z32DEMWK46EBPULYB4CVI2QF4FS3WJ/
> Code of Conduct: http://python.org/psf/codeofconduct/



-- 
Inada Naoki  <songofaca...@gmail.com>
_______________________________________________
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/Q2EPKWPSVG55A3CKVCLJGRX6SPKKSIEE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to