[Python-Dev] Proposal: defaultdict (original) (raw)

Georg Brandl g.brandl at gmx.net
Fri Feb 17 11:55:36 CET 2006


Thomas Heller wrote:

Probably a good idea, has been proposed multiple times on clpy. One good thing would be to be able to specify either a default value or a factory function.

While at it, other interesting dict subclasses could be: * sorteddict, practically reinvented by every larger project You mean ordereddict, not sorteddict, I hope.

Well, yes.

* keytransformdict, such as d = keytransformdict(str.lower). Not sure what you mean by that. What I would like is probably more ambitious: I want a dict that allows case-insensitive lookup of string keys

This is exactly what this would do. All keys are transformed to lowercase when setting and looking up.

plus ideally I want to use it as class or instance dictionary. Use case: COM wrappers.

regards, Georg



More information about the Python-Dev mailing list