[Python-Dev] PEP 455: TransformDict
steve at pearwood.info
Sat Sep 14 05:33:51 CEST 2013
On Fri, Sep 13, 2013 at 06:40:06PM -0700, Ethan Furman wrote:
> >and if you wanted the transformed key you would apply the transform
> >function to the key.
> Indeed. The question is: how? It is entirely possible that your function
> has a TransformDict alone, and no memory of the transform function used to
> create the dict...
> If the key transform function were saved directly on the TransformDict
> instance as, say, .transform_key, then problem solved.
While I think it is good and proper to have the transformation function
available, if you're manually applying the transformation function then
IMO chances are good that you've missed the whole point of the
Think of defaultdict. The purpose of defaultdict is to avoid needing to
check whether the key is missing or not. If I suggested that the way
to use a defaultdict was to write code like this:
value = d[key] if key in d else d.default_factory()
I'd be missing the point. Likewise, the point of transformdict is to
avoid needing to care about the transformation function 99% of the
More information about the Python-Dev