<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#330033" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 9/10/2013 2:46 PM, Antoine Pitrou
wrote:<br>
</div>
<blockquote cite="mid:20130910234659.39284dab@fsol" type="cite">
<blockquote type="cite" style="color: #000000;">
<blockquote type="cite" style="color: #000000;">
<blockquote type="cite" style="color: #000000;">
<pre wrap=""><span class="moz-txt-citetags">> >> </span>Which reminds one - this class should obviously have a method for
<span class="moz-txt-citetags">> >> </span>retrivieng the original key value, given a matching key -
<span class="moz-txt-citetags">> >></span>
<span class="moz-txt-citetags">> >> </span>d.canonical('foo') -> 'Foo'
</pre>
</blockquote>
<pre wrap=""><span class="moz-txt-citetags">> ></span>
<span class="moz-txt-citetags">> > </span>I don't know. Is there any use case?
<span class="moz-txt-citetags">> > </span>(sure, it is trivially implemented)
</pre>
</blockquote>
<pre wrap=""><span class="moz-txt-citetags">> </span>
<span class="moz-txt-citetags">> </span>
<span class="moz-txt-citetags">> </span>Well, I'd expect it to simply be there. I had not thought of
<span class="moz-txt-citetags">> </span>other usecases for the transformdict itself -
</pre>
</blockquote>
<pre wrap="">Well, it is not here for dict, set, etc.
</pre>
</blockquote>
<br>
But they don't change the keys (although numbers have different
representations on occasion).<br>
<br>
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.<br>
<br>
I also thought João's example was a very practical reason to have
the canonical lookup feature, by some name or another.<br>
</body>
</html>