A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-June/025039.html below:

[Python-Dev] d.get_key(key) -> key?

[Python-Dev] d.get_key(key) -> key? [Python-Dev] d.get_key(key) -> key?Ka-Ping Yee ping@zesty.ca
Wed, 5 Jun 2002 16:40:16 -0500 (CDT)
On 5 Jun 2002, Daniel 'eikeon' Krech wrote:
>
> Is there or could there be an efficient way to get an existing key from
> a dictionary given a key that is == but whose id is not. For example:

If i understand you correctly, a good way to solve this problem is to
provide a __hash__ method on the objects that you are using as keys to
your dictionary.  Dictionaries look up keys by hash equality.

Note that you will have to ensure that the keys are immutable (i.e.
once they are put in the dictionary, they should never change).


-- ?!ng





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4