<p dir="ltr">What is the use case of such methods? Why not using dict.kets() and tuple(set)?</p>
<p dir="ltr">Victor<br>
</p>
<div class="gmail_quote">Le 14 sept. 2013 17:09, "Serhiy Storchaka" <<a href="mailto:storchaka@gmail.com">storchaka@gmail.com</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I propose to add two methods:<br>
<br>
dict.getkey(key) returns original key stored in the dict which is equal to specified key. E.g.<br>
<br>
>>> d = {2: 'a', 5.0: 'b'}<br>
>>> d.getkey(2.0)<br>
2<br>
>>> d.getkey(5)<br>
5.0<br>
>>> d.getkey(17)<br>
Traceback (most recent call last):<br>
  File "<stdin>", line 1, in <module><br>
KeyError: 17<br>
<br>
set.get(value) returns original value stored in the set which is equal to specified value. E.g.<br>
<br>
>>> s = {2, 5.0}<br>
>>> s.get(2.0)<br>
2<br>
>>> s.get(5)<br>
5.0<br>
>>> s.get(17)<br>
Traceback (most recent call last):<br>
  File "<stdin>", line 1, in <module><br>
KeyError: 17<br>
<br>
______________________________<u></u>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-ideas</a><br>
</blockquote></div>