Home / Function/ _encode_params() — requests Function Reference

_encode_params() — requests Function Reference

Architecture documentation for the _encode_params() function in models.py from the requests codebase.

Function python CoreAPI VerbHandlers calls 1 called by 2

Entity Profile

Dependency Diagram

graph TD
  05aa4b39_ee11_5653_43fd_4e9fe439edad["_encode_params()"]
  f47304c1_b2c6_e66a_f59e_e2534a06b3c8["RequestEncodingMixin"]
  05aa4b39_ee11_5653_43fd_4e9fe439edad -->|defined in| f47304c1_b2c6_e66a_f59e_e2534a06b3c8
  77892816_404a_4492_b558_b565f63d2ad0["prepare_url()"]
  77892816_404a_4492_b558_b565f63d2ad0 -->|calls| 05aa4b39_ee11_5653_43fd_4e9fe439edad
  fdb744d2_4cc0_a0f9_c288_a0abeac5e58e["prepare_body()"]
  fdb744d2_4cc0_a0f9_c288_a0abeac5e58e -->|calls| 05aa4b39_ee11_5653_43fd_4e9fe439edad
  1d5603b3_e7c9_dfae_a29a_d8c05ae35261["to_key_val_list()"]
  05aa4b39_ee11_5653_43fd_4e9fe439edad -->|calls| 1d5603b3_e7c9_dfae_a29a_d8c05ae35261
  style 05aa4b39_ee11_5653_43fd_4e9fe439edad fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/requests/models.py lines 109–136

    def _encode_params(data):
        """Encode parameters in a piece of data.

        Will successfully encode parameters when passed as a dict or a list of
        2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
        if parameters are supplied as a dict.
        """

        if isinstance(data, (str, bytes)):
            return data
        elif hasattr(data, "read"):
            return data
        elif hasattr(data, "__iter__"):
            result = []
            for k, vs in to_key_val_list(data):
                if isinstance(vs, basestring) or not hasattr(vs, "__iter__"):
                    vs = [vs]
                for v in vs:
                    if v is not None:
                        result.append(
                            (
                                k.encode("utf-8") if isinstance(k, str) else k,
                                v.encode("utf-8") if isinstance(v, str) else v,
                            )
                        )
            return urlencode(result, doseq=True)
        else:
            return data

Domain

Subdomains

Frequently Asked Questions

What does _encode_params() do?
_encode_params() is a function in the requests codebase, defined in src/requests/models.py.
Where is _encode_params() defined?
_encode_params() is defined in src/requests/models.py at line 109.
What does _encode_params() call?
_encode_params() calls 1 function(s): to_key_val_list.
What calls _encode_params()?
_encode_params() is called by 2 function(s): prepare_body, prepare_url.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free