#This program displays the contents of all files that end in .py import glob # glob supports unix style pathname extensions #Set up an object that contains the names of all files that fit the pattern *.py python_files = glob.glob('*.py') #Loop for file_name in sorted(python_files): print ' ------' + file_name with open(file_name) as f: for line in f: print ' ' + line.rstrip() #rstrip removes trailing blanks etc. print