title: Python: Why can't I iterate over a list? Is my exception class borked?
body: <p>I've already looked at this question: <a href="https://stackoverflow.com/questions/1152238/python-iterators-how-to-dynamically-assign-self-next-within-a-new-style-class">Python iterators – how to dynamically assign self.next within a new style class?</a></p>
  
  <p>but this doesn't help me because I want to iterate of an attribute of the error which is a list (ie, already iterable) without having to use the attribute explicitly. I'm looking to do this:</p>
  
  <pre><code>class SCE(Exception):
      """
      An error while performing SCE functions.
      """
      def __init__(self, value=None):
          """
          Message: A string message or an iterable of strings.
          """
          if value is None:
              self._values = ['A general SCE error has occured.']
          elif isinstance(value, str):
              self._values = [value]
          else:
              self._values = list(value)
  
      def __iter__(self):
          return self._values
  
      def __repr__(self):
          return repr(self._values)
  </code></pre>
  
  <p>However, in the shell I get this:</p>
  
  <pre><code>try:
      raise CSE(['error one', 'error two'])
  except CSE, e:
      for i in e:
          print(i)
  Traceback (most recent call last):
    File "(stdin)", line 1, in (module)
  TypeError: iter() returned non-iterator of type 'list'
  </code></pre>
  
  <p>I know I could remove the _ from _values and then iterate over e.values but I don't want to do that as it exposes the implementation of my Exception class.</p>