pg.format¶
Accessible via pg.format, pg.utils.format.
- format(value, compact=False, verbose=True, root_indent=0, list_wrap_threshold=80, strip_object_id=False, include_keys=None, exclude_keys=None, markdown=False, max_str_len=None, max_bytes_len=None, *, custom_format=None, memo=None, **kwargs)[source]¶
Formats a (maybe) hierarchical value with flags.
- Return type:
- Parameters:
value – The value to format.
compact – If True, this object will be formatted into a single line.
verbose – If True, this object will be formatted with verbosity. Subclasses should define verbosity on their own.
root_indent – The start indent level for this object if the output is a multi-line string.
list_wrap_threshold – A threshold in number of characters for wrapping a list value in a single line.
strip_object_id – If True, format object as ‘<class-name>(…)’ other than ‘object at <address>’.
include_keys – A set of keys to include from the top-level dict or object.
exclude_keys – A set of keys to exclude from the top-level dict or object. Applicable only when include_keys is set to None.
markdown – If True, use markdown notion to quote the formatted object.
max_str_len – The max length of the string to be formatted. If the string is longer than this length, it will be truncated.
max_bytes_len – The max length of the bytes to be formatted. If the bytes is longer than this length, it will be truncated.
custom_format – An optional custom format function, which will be applied to each value (and child values) in kvlist. If the function returns None, it will fall back to the default pg.format.
memo – A set of object ids that have been formatted. Used to avoid infinite recursion in the formatting process.
**kwargs – Keyword arguments that will be passed through unto child
Formattableobjects.
- Returns:
A string representation for value.