title: Overriding append method after inheriting from a Python List
body: <p>I want to create a list that can only accept certain types. As such, I'm trying to inherit from a list in Python, and overriding the append() method like so:</p>
  
  <pre><code>class TypedList(list):
      def __init__(self, type):
          self.type = type
  
      def append(item)
          if not isinstance(item, type):
              raise TypeError, 'item is not of type %s' % type
          self.append(item)  #append the item to itself (the list)
  </code></pre>
  
  <p>This will of cause an infinite loop because the body of append() calls itself, but I'm not sure what to do other than using self.append(item).</p>
  
  <p>How I should go about doing this?</p>