I have a simple text file with several thousands of words, each in its own line, e.g.
aardvark hello piper
I use the following code to load
The strip() method of strings removes whitespace from both ends.
set(line.strip() for line in open('filename.txt'))