#------------------------------------------------------------------------------ # # TestAnagramDictionary.py # # Use this program to test your function AnagramDictionary() in pa6. This # program produces a file called my_anagrams.txt in your current directory. # This file is rather large (about 5.7 MB) so you may want to delete it after # the test if you are doing this on the timeshare. Download and save the file # anagrams.txt from /Examples/pa6 to the same directory. In Linux or Mac do # # $ diff anagrams.txt my_anagrams.txt # # On Windows Powershell do # # > diff (cat anagrams.txt) (cat my_anagrams.txt) # # In both cases, no output indicates that the files are the same, which is # a success. Consider this a weak test of your AnagramDictionary() function. # #------------------------------------------------------------------------------ import Scrabble # main() ---------------------------------------------------------------------- def main(): infile = open('scrabble.txt') outfile = open('my_anagrams.txt', 'w') A = Scrabble.AnagramDictionary(infile) print('key', 15*' ' , 'anagrams', file=outfile) print(60*'-', file=outfile) for k in A: print( '{0:<20}{1}'.format(k, A[k]), file=outfile ) # end for infile.close() outfile.close() # end main() ------------------------------------------------------------------ # ----------------------------------------------------------------------------- if(__name__=='__main__'): main() # end if ----------------------------------------------------------------------