title: Python __iter__ and next() functions
body: <p>In Python... </p>
  
  <p>I have a nested list defined in a class as:</p>
  
  <pre><code>self.env = [[ None for i in range(columnCount)] for j in range(rowCount) ]       
  </code></pre>
  
  <p>For the purpose of this question, lets assume this nested list contained values of:</p>
  
  <pre><code>[None, None, None, None]
  [None, None, None, None]
  [None, None, 0, None]
  [None, None, None, None]
  </code></pre>
  
  <p>I need to be able to leverage the <strong>iter</strong> and next() methods to go through this list in column major order (row0,col0 row1,col0, row2,col0...).</p>
  
  <p>The intent is for it to send the value located in that grid location to another function to get processed.</p>
  
  <p>So far I have the <strong>iter</strong> function defined as:</p>
  
  <pre><code>def __iter__(self):
      return iter(self.env)
  </code></pre>
  
  <p>Then I have the next function defined as:</p>
  
  <pre><code>def next(self):
      self.currentRow += 1
      self.currentColumn += 1
  
      if ( (self.currentRow &lt; self.getRowCount()) and (self.currentColumn &lt; self.getColumnCount()) ):
          return self.env[self.currentRow][self.currentColumn]
      else:
          raise StopIteration
  </code></pre>
  
  <p>The problem I am having is that it seems the <strong>iter</strong> function is return each row as a list, but it is not making a call to the next method to further process that list.</p>
  
  <p>My objective is to get print the values at each grid location invdividually... as in:</p>
  
  <p>None
  None
  ...
  None
  0
  None
  ...
  None</p>
  
  <p>Can someone elaborate on what it is I am missing in order to accomplish this?</p>