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/2013-September/128551.html below:

[Python-Dev] Add a "transformdict" to collections

[Python-Dev] Add a "transformdict" to collectionsGlenn Linderman v+python at g.nevcal.com
Wed Sep 11 03:15:33 CEST 2013
On 9/10/2013 2:46 PM, Antoine Pitrou wrote:
>>>> > >>Which reminds one - this class should obviously have a method for
>>>> > >>retrivieng the original key value, given a matching key -
>>>> > >>
>>>> > >>d.canonical('foo') -> 'Foo'
>>> > >
>>> > >I don't know. Is there any use case?
>>> > >(sure, it is trivially implemented)
>> >
>> >
>> >Well, I'd expect it to simply be there. I had not thought of
>> >other usecases for the transformdict itself -
> Well, it is not here for dict, set, etc.

But they don't change the keys (although numbers have different 
representations on occasion).

One use of transformdict might be to allow use of non-hashable items as 
keys, by extracting an actual key from the internals of the non-hashable 
item. The key may be sufficiently unique to enable use of the dict 
structure for lookups, but it would certainly be handy to obtain the 
actual item again. Without a canonical lookup feature, one would be 
forced to also include the key as part of the value, or some such hack.

I also thought João's example was a very practical reason to have the 
canonical lookup feature, by some name or another.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130910/5dde4a29/attachment.html>
More information about the Python-Dev mailing list

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