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

Ethan Furman ethan at stoneleaf.us
Wed Sep 11 16:17:29 CEST 2013

On 09/11/2013 02:38 AM, Serhiy Storchaka wrote:
> There is a question about specifying the transform function.
> There are three ways to do this:
> 1. Positional argument of the constructor.
> d = TransformDict(str.casefold, Foo=5)

This method follows the precedent of defaultdict:

--> from collections import defaultdict
--> l = defaultdict(list, foo=['ham','eggs'])
--> l
defaultdict(<class 'list'>, {'foo': ['ham', 'eggs']})

Without a compelling reason to change, we should keep it consistent.


More information about the Python-Dev mailing list