
# iterators-based Fibonacci number finder (f_i = f_(i-1) + f_(i-2)),
# adapted from Practical Python by Hetland

# class fibs will be identified as an iterator class by the presence of
# next() and __iter__()

class fibs:
    def __init__(self):
        self.a = 0
        self.b = 1
    def next(self):
        self.a, self.b = self.b, self.a+self.b
        return self.a
    def __iter__(self):
        return self

for i in fibs():  # iterator class callable, outputs considered a list
   if i > 100: break  # would go forever without this
   print i


