def getWords(filepath): with open('filepath') as f: return list(itertools.chain(line.split() for line in f))