title: Confused with python lists: are they or are they not iterators?
body: <p>I am studying <a href="https://rads.stackoverflow.com/amzn/click/com/0596100469" rel="noreferrer" rel="nofollow noreferrer">Alex Marteli's Python in a Nutshell</a> and the book suggests that any object that has a <code>next()</code> method is (or at least can be used as) an <strong>iterator</strong>. It also suggests that most iterators are built by implicit or explicit calls to a method called <code>iter</code>.</p>
  
  <p>After reading this in the book, I felt the urge to try it. I fired up a python 2.7.3 interpreter and did this:</p>
  
  <pre><code>&gt;&gt;&gt; x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  &gt;&gt;&gt; for number in range(0, 10):
  ...     print x.next()
  </code></pre>
  
  <p>However the result was this:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 2, in &lt;module&gt;
  AttributeError: 'list' object has no attribute 'next'
  </code></pre>
  
  <p>In confusion, I tried to study the structure of the x object via <code>dir(x)</code> and I noticed that it had a <code>__iter__</code> function object. So I figured out that it can be used as an iterator, so long as it supports that type of interface.</p>
  
  <p>So when I tried again, this time slightly differently, attempting to do this:</p>
  
  <pre><code>&gt;&gt;&gt; _temp_iter = next(x)
  </code></pre>
  
  <p>I got this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  TypeError: list object is not an iterator
  </code></pre>
  
  <p>But how can a list NOT be an iterator, since it appears to support this interface, and can be certainly used as one in the following context:</p>
  
  <pre><code>&gt;&gt;&gt; for number in x:
  ...     print x
  </code></pre>
  
  <p><strong>Could someone help me clarify this in my mind?</strong></p>