How to find all .yml and .yaml files using a single glob pattern? Desired output:
>>> import os, glob
>>> os.listdir('.')
['f1.yaml', 'f2.yml', 'f0.txt']
>>> glob.glob(pat)
['f1.yaml', 'f2.yml']
Attempts that don't work:
>>> glob.glob("*.ya?ml")
[]
>>> glob.glob("*.y[a]ml")
['f1.yaml']
Current workaround is globbing twice, but I want to know if this is possible with a single pattern.
>>> glob.glob('*.yaml') + glob.glob('*.yml')
['f1.yaml', 'f2.yml']
Not looking for more workarounds, if this is not possible with a single pattern then I'd like to see an answer like "glob can not find .yaml
and .yml
files with a single pattern because of these reasons..."