I'm trying to write a correct iteration over a doubly indexed container, and what I've got so far is: def __next__ (self):
        for row    in    range(self._rows):
            for col in range(self._cols):
                if self._grid[row][col]:
                    yield    self._grid[row][col]
                #end    if
            #end    for col
        #end    for row
        raise    StopIteration

What bothers me is that it doesn't look like it would continue to raise StopIteration if it were called again, which is what https://docs.python.org/3/library/stdtypes.html#iterator.__next__ says is correct. How should this be fixed?
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to