Python glob: Finding files that match a pattern with pathlib

Python glob: Finding files that match a pattern with pathlib

Want files in a directory that match a pattern? Use Python’s glob and get strings (filenames). Or use the “glob” method in pathlib:

from pathlib import Path
p = Path('/etc/')
for one_result in p.glob('*.conf'):
    print(f'{one_result=}', end=' ')