def int_sequence(start, end):
    'An integer sequence implemented using a generator function'
    current = start
    while current < end:
        yield current
        current += 1



class IntSequence:
    'An integer sequence implemented as an iterator class'

    def __init__(self, start, end):
        self._start = start
        self._end = end
        self._current = start


    def __iter__(self):
        return self


    def __next__(self):
        if self._current &gt;= self._end:
            raise StopIteration
        else:
            result = self._current
            self._current += 1
            return result
