Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!news2.hunter.apana.org.au!brushtail.apana.org.au!eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Veek M Newsgroups: comp.lang.python Subject: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle. Followup-To: comp.lang.python Date: Fri, 07 Nov 2014 16:46:19 +0630 Organization: Home Lines: 24 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Fri, 7 Nov 2014 11:16:10 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a30578f1d04a7c8924885f0f7a3e47c6"; logging-data="8697"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+I0sV2GBhszeDGIbv0sa83" User-Agent: KNode/4.4.11 Cancel-Lock: sha1:lVH5kVbiuWGpjIqnwuZ8/cJogQU= Xref: csiph.com comp.lang.python:80382 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