structures

Data structures that power Requests.

Module Contents

Classes

CaseInsensitiveDict(self,data=None,**kwargs) A case-insensitive dict-like object.
LookupDict(self,name=None) Dictionary lookup object.
class CaseInsensitiveDict(data=None, **kwargs)

A case-insensitive dict-like object.

Implements all methods and operations of collections.MutableMapping as well as dict’s copy. Also provides lower_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(), iterkeys(), and iteritems() 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.

If the constructor, .update, or equality comparison operations are given keys that have equal ``.lower()``s, the behavior is undefined.

__init__(data=None, **kwargs)
__setitem__(key, value)
__getitem__(key)
__delitem__(key)
__iter__()
__len__()
lower_items()

Like iteritems(), but with all lowercase keys.

__eq__(other)
copy()
__repr__()
class LookupDict(name=None)

Dictionary lookup object.

__init__(name=None)
__repr__()
__getitem__(key)
get(key, default=None)