I am trying to find all the .c files in a directory using Python.
.c
I wrote this, but it is just returning me all files - not just .c files.
import os, re cfile = re.compile("^.*?\.c$") results = [] for name in os.listdir(directory): if cfile.match(name): results.append(name)