YAML

Read a single data object from a string

nb: you need to add the Loader=yaml.FullLoader part or else pyyaml gives a (harmless) warning

Read a single object from a file

Same as above, now from data.yaml

Read multiple objects from a file (YAML stream)

yaml.load_all can read a yaml stream.

Here multiple items are separated by a line with "---". NB: the first "---" is optional (they just need to separate the objects)

from a string

from a file

same thing from data_stream.yaml

You can also use list to convert the generator into a list of dictionaries