glob returns an unsorted list of matching files. You can call the sort() method to get what you want: import glob filelist = glob.glob( '*.py' ) filelist.sort() for filename in filelist: # process filename... Enjoy ! Emmanuel