execfile("my.py") def checkword(word): return int(random()*1.9) def striphelper(inchar): if inchar.isalpha() or inchar=="'": return inchar else: return " " def strippunctuation(instring): return "".join(map( striphelper, instring )) def spellcheckfile(filename): file = open(filename) wordlist = strippunctuation(file.read()).split() mispelled = {} for w in wordlist: if not checkword(w): if mispelled.get(w): mispelled[w]=mispelled[w]+1 else: mispelled[w]=1 return mispelled def spellcheckreport(filename): dict = spellcheckfile(filename) l = list(dict) l.sort() for i in l: print i+' ('+str(dict[i])+')'