[Python-Dev] PEP 455: TransformDict (original) (raw)
Ethan Furman ethan at stoneleaf.us
Sat Sep 14 18:43:13 CEST 2013
- Previous message: [Python-Dev] PEP 455: TransformDict
- Next message: [Python-Dev] PEP 455: TransformDict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 09/14/2013 03:27 AM, Antoine Pitrou wrote:
On Fri, 13 Sep 2013 21:59:11 -0700 Ethan Furman <ethan at stoneleaf.us> wrote:
I mean - given no function to retrieve the canonical key, one would have to resort to:
mykey = data.transform(givenkey) for key, value in data.items(): if data.transform(key) == mykey: .... Which is exactly why I, and others, would like to have the transform function easily available. Besides being able to use it to get a canonical key, one could use it to get the function itself. Yay, introspection! Well, no, you misunderstand :) The transform function takes an original key (perhaps "canonical") and returns the transformed key, it can't do the reverse which is what getitem() does. i.e.:
Argh, of course you are right.
Still, I think it would be useful to expose the transform function. Any good reason not to?
--
Ethan
- Previous message: [Python-Dev] PEP 455: TransformDict
- Next message: [Python-Dev] PEP 455: TransformDict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]