class Count(object): def __init__(self, start=0, step=1, stop=10): self.n = start self.step = step self.stop = stop def __next__(self): n = self.n if n>self.stop: raise StopIteration() self.n += self.step return n def __iter__(self): return self