pformat
pformat is a function in Python's standard library module pprint. It returns a string containing a pretty-printed representation of a Python object, intended for readable display in logs, error messages, or user interfaces. It mirrors the behavior of the helper function pprint, but instead of printing to stdout, pformat returns the formatted string.
pformat formats common Python types such as lists, tuples, dictionaries, sets, and nested containers by inserting
By default, pformat aims for a readable, multi-line representation, but with very wide containers or when compact
Typical use is to assign the result to a string for inclusion in logs or error messages,
See also: the pprint module in Python’s standard library, its related functions such as pprint and the