On Tue, 10 Sep 2013 16:21:18 +0100, Nigel Small firstname.lastname@example.org 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.
MIME-Version Message-ID Content-Type
For network protocols you really do want to *preserve* the case.