title: Object has no attribute 'lower'
body: <p>I'm working on a problem set from the MIT OpenCourseWare course (with no credit whatsoever) and came across this problem. I'm trying to create an RSS Feed filter. </p>
  
  <p>I first created an object that defines the characteristics of a news story.</p>
  
  <pre><code>class NewsStory(object):
      def __init__(self, guid, title, subject, summary, link):
          self.guid = guid
          self.title = title
          self.subject = subject
          self.summary = summary
          self.link = link
  
      def get_guid(self):
          return self.guid
  
      def get_title(self):
          return self.title
  
      def get_subject(self):
          return self.subject
  
      def get_summary(self):
          return self.summary
  
      def get_link(self):
          return self.link
  </code></pre>
  
  <p>Next, this is the given class for a trigger. </p>
  
  <pre><code>class Trigger(object):
      def evaluate(self, story):
          """
          Returns True if an alert should be generated
          for the given news item, or False otherwise.
          """
  
          raise NotImplementedError
  </code></pre>
  
  <p>I then tried to create a subclass of Trigger, WordTrigger, to check if a word is in the text that I want to check.</p>
  
  <pre><code>class WordTrigger(Trigger):
      def __init__(self, word):
          self.word = word
  
      def is_word_in(self, text):
          word = self.word.lower()
          text = text.lower() 
  
          for p in string.punctuation:
              if p in text:
                  text.replace(p, ' ')
  
          print self.word in text
  </code></pre>
  
  <p>To call <code>is_word_in</code>, I used another subclass of WordTrigger, TitleTrigger. </p>
  
  <pre><code>class TitleTrigger(WordTrigger):
  
      def evaluate(self, story):
          return self.is_word_in(story.get_title())
  </code></pre>
  
  <p>However, running the unit test for this gives me a new error (after editing the code): </p>
  
  <p><code>AssertionError: TitleTrigger failed to fire when the word appeared in the title</code></p>
  
  <p>Right now I'm not sure if the error is because of something wrong with conversion of lower to uppercase? </p>
  
  <p>Here is the unit test that was given to me: (I included what I think are the relevant parts)</p>
  
  <pre><code>class ProblemSet5NewsStory(unittest.TestCase):
      def setUp(self):
          pass
      def testNewsStoryConstructor(self):
          add_potential_points(1)
          story = NewsStory('', '', '', '', '')
          add_points(1)
  
  class ProblemSet5(unittest.TestCase):
      def setUp(self):
          class TrueTrigger:
              def evaluate(self, story): return True
  
          class FalseTrigger:
              def evaluate(self, story): return False
  
          self.tt = TrueTrigger()
          self.tt2 = TrueTrigger()
          self.ft = FalseTrigger()
          self.ft2 = FalseTrigger()
  
      def test1TitleTrigger(self):
          add_potential_points(5)
          koala     = NewsStory('', 'Koala bears are soft and cuddly', '', '', '')
          pillow    = NewsStory('', 'I prefer pillows that are soft.', '', '', '')
          soda      = NewsStory('', 'Soft drinks are great', '', '', '')
          pink      = NewsStory('', "Soft's the new pink!", '', '', '')
          football  = NewsStory('', '"Soft!" he exclaimed as he threw the football', '', '', '')
          microsoft = NewsStory('', 'Microsoft announced today that pillows are bad', '', '', '')
          nothing   = NewsStory('', 'Reuters reports something really boring', '', '' ,'')
          caps      = NewsStory('', 'soft things are soft', '', '', '')
  
          s1 = TitleTrigger('SOFT')
          s2  = TitleTrigger('soft')
          for trig in [s1, s2]:
              self.assertTrue(trig.evaluate(koala), "TitleTrigger failed to fire when the word appeared in the title")
              self.assertTrue(trig.evaluate(pillow), "TitleTrigger failed to fire when the word had punctuation on it")
              self.assertTrue(trig.evaluate(soda), "TitleTrigger failed to fire when the case was different")
              self.assertTrue(trig.evaluate(pink), "TitleTrigger failed to fire when the word had an apostrophe on it")
              self.assertTrue(trig.evaluate(football), "TitleTrigger failed to fire in the presence of lots of punctuation")
              self.assertTrue(trig.evaluate(caps), "TitleTrigger is case-sensitive and shouldn't be")
  
              self.assertFalse(trig.evaluate(microsoft), "TitleTrigger fired when the word was present, but not as its own word (e.g. 'soft' and 'Microsoft)'")
              self.assertFalse(trig.evaluate(nothing), "TitleTrigger fired when the word wasn't really present in the title")
  </code></pre>
  
  <p>I'm rather confused with how to make use of attributes in classes, especially when inheritance comes into play. Would really appreciate any help! </p>