A note about the different newline syntax in YAML.

Suppose test.yaml has the following content:

a: |
  z
  w

b: >
  z
  w

c: >-
  z
  w

Loading it with PyYAML:

>>> import yaml
>>> with open('./test.yaml') as opened:
...     yaml.safe_load(opened)
... 
{'a': 'z\nw\n', 'b': 'z w\n', 'c': 'z w'}

So

  • | keeps all newline characters (\n).
  • > only keeps the last newline character.
  • >- removes all newline characters.