pg.format

Accessible via pg.format, pg.object_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, **kwargs)[source]

Formats a (maybe) hierarchical value with flags.

Return type:

str

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.

  • **kwargs – Keyword arguments that will be passed through unto child Formattable objects.

Returns:

A string representation for value.