from pathlib
import Path for filename in Path('src').glob('**/*.c'):
print(filename)
fnmatch.fnmatch():-
Function fnmatch.fnmatch() tests whether the given filename string matches the pattern string and returns a boolean value. If the operating system is case-insensitive, then both parameters will be normalized to all lower-case or upper-case before the comparison is performed.
import os, fnmatch
def find_files(directory, pattern):
for root, dirs, files in os.walk(directory):
for basename in files:
if fnmatch.fnmatch(basename, pattern):
filename = os.path.join(root, basename)
yield filename
for filename in find_files('src', '*.c'):
print ('Found C source:', filename)