import dawg with open('/usr/share/dict/words','r') as f: words = (w.strip() for w in f) d = dawg.DAWG(words, input_is_sorted=True)