format_yaml()function

Serialize a Python value to a YAML string.

USAGE

format_yaml(
    value,
    multi=False,
)

Parameters

value : object

Python value or Yaml to serialize; for multi the value must be a sequence of documents.

multi : bool = False

Emit a multi-document stream when true; otherwise a single document.

Returns

str : str

YAML text; multi-document streams end with ....

Raises

TypeError

When multi is true and value is not a sequence, or unsupported types are provided.

Examples

>>> format_yaml({'foo': 1})
'foo: 1'
>>> format_yaml(['first', 'second'], multi=True).endswith('...\n')
True