title: Appending into fix-sized list
body: <p>I'm looking for a simple way to appending into fix-sized list. </p>
  
  <p>If the list has max value <code>n</code> and there is another item appended into this list, the first item of the <code>list</code> would be removed. </p>
  
  <p>There is a way but I think it is not efficient and it's quite overkill. How should I do this?</p>
  
  <pre><code>class fix_sized_list():
      def __init__(self,_max):
          self.max = _max
          self._list = []
  
      def add(self,item):
          print len(self._list)
          if len(self._list)&gt;=self.max:
              self._list.pop(0)
              self._list.append(item)
          else:
              self._list.append(item)
  
  
  c = fix_sized_list(8)
  
  for x in range(50):
      c.add(x)
      print c._list
  </code></pre>
  
  <p><strong>OUTPUT:</strong></p>
  
  <pre><code>[0]
  [0, 1]
  [0, 1, 2]
  [0, 1, 2, 3]
  [0, 1, 2, 3, 4]
  [0, 1, 2, 3, 4, 5]
  [0, 1, 2, 3, 4, 5, 6]
  [0, 1, 2, 3, 4, 5, 6, 7]
  [1, 2, 3, 4, 5, 6, 7, 8]
  [2, 3, 4, 5, 6, 7, 8, 9]
  </code></pre>