title: Python: load words from file into a set
body: <p>I have a simple text file with several thousands of words, each in its own line, e.g.</p>
  
  <pre><code>aardvark
  hello
  piper
  </code></pre>
  
  <p>I use the following code to load the words into a set (I need the list of words to test membership, so set is the data structure I chose):</p>
  
  <pre><code>my_set = set(open('filename.txt'))
  </code></pre>
  
  <p>The above code produces a set with the following entries (each word is followed by a space and new-line character:</p>
  
  <pre><code>("aardvark \n", "hello \n", "piper \n")
  </code></pre>
  
  <p>What's the simplest way to load the file into a set but get rid of the space and \n?</p>
  
  <p>Thanks</p>