libb.CaseInsensitiveDict
- class CaseInsensitiveDict(data=None, **kwargs)[source]
Bases:
MutableMappingA case-insensitive dictionary-like object.
Implements all methods and operations of
MutableMappingas well as dict’scopy. Also provideslower_items.All keys are expected to be strings. The structure remembers the case of the last key to be set, and
iter(instance),keys(),items()will contain case-sensitive keys. However, querying and contains testing is case insensitive:cid = CaseInsensitiveDict() cid[‘Accept’] = ‘application/json’ cid[‘aCCEPT’] == ‘application/json’ # True list(cid) == [‘Accept’] # True
For example,
headers['content-encoding']will return the value of a'Content-Encoding'response header, regardless of how the header name was originally stored.Note
If the constructor,
.update, or equality comparison operations are given keys that have equal.lower()values, the behavior is undefined.