An ordered dictionary for the Python library?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Wed Sep 12 08:52:55 EDT 2007
On Wed, 12 Sep 2007 09:51:02 +0200, stef wrote:
> If you're going to extend the dictionary, there's one other flag I'm
> continuously missing: "case-insensitive" key.
Completely untested and probably buggy as anything, but here's an
absolutely minimal case-insensitive dictionary.
class CaselessDict(dict):
def __setitem__(self, key, value):
super(CaselessDict, self).__setitem__(key.lower(), value)
def __getitem__(self, key):
return super(CaselessDict, self).__getitem__(key.lower())
--
Steven.
More information about the Python-list
mailing list