from_key_val_list() — requests Function Reference
Architecture documentation for the from_key_val_list() function in utils.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD 14516cbd_cafb_386c_a96b_ece00c5c8bf8["from_key_val_list()"] 2c39b9da_e317_5e6c_bbac_8362bac2110c["utils.py"] 14516cbd_cafb_386c_a96b_ece00c5c8bf8 -->|defined in| 2c39b9da_e317_5e6c_bbac_8362bac2110c style 14516cbd_cafb_386c_a96b_ece00c5c8bf8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/requests/utils.py lines 306–330
def from_key_val_list(value):
"""Take an object and test to see if it can be represented as a
dictionary. Unless it can not be represented as such, return an
OrderedDict, e.g.,
::
>>> from_key_val_list([('key', 'val')])
OrderedDict([('key', 'val')])
>>> from_key_val_list('string')
Traceback (most recent call last):
...
ValueError: cannot encode objects that are not 2-tuples
>>> from_key_val_list({'key': 'val'})
OrderedDict([('key', 'val')])
:rtype: OrderedDict
"""
if value is None:
return None
if isinstance(value, (str, bytes, bool, int)):
raise ValueError("cannot encode objects that are not 2-tuples")
return OrderedDict(value)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does from_key_val_list() do?
from_key_val_list() is a function in the requests codebase, defined in src/requests/utils.py.
Where is from_key_val_list() defined?
from_key_val_list() is defined in src/requests/utils.py at line 306.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free