03.12.19 02:25, Soni L. пише:
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.
It was discussed before. The conclusion was that there are too small use
cases for this (although with adding := and discussing the addition of +
for dicts this is no longer considered a strong argument) and in these
cases a dict works as well as a set.
_______________________________________________
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/KCAA6YLZXP3ZAY4DCZYGP3HCE7ZE3QFC/
Code of Conduct: http://python.org/psf/codeofconduct/