'Does ruamel.yaml have a function to do the process with all files in one directory?

Does ruamel.yaml have a function to do the process with all files in one directory? Something like this: data = yaml.load(Path("*.*"))



Solution 1:[1]

No, it does not, but you can do it one line (assuming you have the imports and the YAML() instance):

from pathlib import Path
import ruamel.yaml

yaml = ruamel.yaml.YAML()

data = [yaml.load(p) for p in Path('.').glob('*.yaml')]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anthon