FWIW, you can do it with dict already. o = memo.setdefault(o, o)
On Tue, Dec 3, 2019 at 9:29 AM Soni L. <[email protected]> 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 -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/T3Z32DEMWK46EBPULYB4CVI2QF4FS3WJ/ > Code of Conduct: http://python.org/psf/codeofconduct/ -- Inada Naoki <[email protected]> _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/Q2EPKWPSVG55A3CKVCLJGRX6SPKKSIEE/ Code of Conduct: http://python.org/psf/codeofconduct/
