how to do ls in python
October 29th, 2006 by Lawrence David
glob is a handy way to do a directory listing in python.
for instance, to return a list of all the text files in a directory, you could command:
import glob
glob.glob(“/mypath/*.txt”)
(glob handles *,?, and [] matching).