Thomas Heller wrote: > I forgot to mention this: The Base class also implements a __getitem__ > method which should be used for iteration if the .Iterator method in the > subclass is not available. So it seems impossible to raise an exception > in the __iter__ method if .Iterator is not found - __iter__ MUST return > an iterator if present.
def Iterator(self): for index in xrange(len(self)): yield self[index] def __iter__(self): return self.Iterator() ...and then override Iterator in subclasses. But this raises the question of why you need to use a specially-named method instead of having subclasses override the __iter__. -- http://mail.python.org/mailman/listinfo/python-list