But how come a raise StopIteration in the next() method doesnt need to be caught ? It works without breaking.
class twoTimes: max = 10**10 def __init__(self, n): self.__n = n def next(self): if self.__n > self.max: raise StopIteration self.__n *= 2 return self.__n def __iter__(self): return self t = twoTimes(5) c = 0 print (t.next()) print (t.next()) for n in t: print n Anjanesh -- http://mail.python.org/mailman/listinfo/python-list