[Python-Dev] Add a "transformdict" to collections
R. David Murray
rdmurray at bitdance.com
Tue Sep 10 20:28:00 CEST 2013
On Tue, 10 Sep 2013 16:21:18 +0100, Nigel Small <nigel at nigelsmall.com> wrote:
> Could a more generic variant of this class work? In the same way that
> `sorted` can accept a comparison function, similar could be done for a
> dictionary-like class:
> d = transformdict(key=str.lower)
> Strictly speaking, this would provide case-insensitive but not
> case-preserving behaviour. For any given use case, though, a function could
> instead be supplied to "normalise" the key (upper, lower, title case, etc)
> in a way that fits that case. I can't think of many real cases where
> multiple types of capitalisation would be useful within the same dictionary.
For network protocols you really do want to *preserve* the case.
More information about the Python-Dev