How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

Veek M vek.m1234 at gmail.com
Fri Nov 7 05:16:19 EST 2014


    def jump_to_blockD(self):
        end = len(self.b)
        row, col = self.w.cursor
        while row <= end:
            try:
                new_col = self.b[row].index('def')
                self.w.cursor = row, new_col
                break
            except ValueError:
                pass
            row += 1

    def jump_to_blockU(self):
        end = 0
        row, col = self.w.cursor
        while row >= end:
            try:
                new_col = self.b[row].rindex('def')
                self.w.cursor = row, new_col
                break
            except ValueError:
                pass
            row -= 1






More information about the Python-list mailing list