title: String operations in Python
body: <p>I'm trying to get into NLP using NLTK and I understand most of the code below, but I don't understand what <code>x.sub("", word)</code> and <code>if not new_word in ""</code> mean. I'm confused.</p>
  
  <pre><code>text = ["It is a pleasant evening.", "Guests, who came from the US arrived at the venue.", "Food was tasty."]
  
  tokenized_docs = [word_tokenize(doc) for doc in text]
  print(tokenized_docs)
  
  x = re.compile("[%s]" % re.escape(string.punctuation))
  token_nop = []
  for sentence in tokenized_docs:
      new_sent = []
      for word in sentence:
          new_word = x.sub('', word)
          if not new_word in '':
              sentence.append(new_word)
      token_nop.append(sentence)
  </code></pre>