class TenIntegers: def __init__(self, start_from=0): self.current=start_from self.max = self.current + 10 def __iter__(self): ''' This method makes the object iterable ''' return self def __next__(self): ''' This is the actual method used on iteration ''' if self.current < self.max: current_value = self.current self.current += 1 return current_value else: # This error is raised to stop the iteration raise StopIteration # Useful to call it manually next = __next__