title: Why is an iterable object not an iterator?
body: <p>Here is my code:   </p>
  
  <pre><code>from collections import deque
  
  class linehistory:
      def __init__(self, lines, histlen=3):
          self.lines = lines
          self.history = deque(maxlen=histlen)
  
      def __iter__(self):
          for lineno, line in enumerate(self.lines,1):
              self.history.append((lineno, line))
              yield line
  
      def clear(self):
          self.history.clear()
  
  
  f = open('somefile.txt')
  lines = linehistory(f)
  next(lines)
  </code></pre>
  
  <p>Error:</p>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
      TypeError: 'linehistory' object is not an iterator
  </code></pre>
  
  <p>I have no idea why the <code>linehistory</code> object is not an iterator since it has already included <code>__iter__</code> method in <code>the</code> class.</p>