Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Veek M Newsgroups: comp.lang.python Subject: Re: 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 21:22:22 +0630 Organization: Home Lines: 11 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Fri, 7 Nov 2014 15:52:13 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a30578f1d04a7c8924885f0f7a3e47c6"; logging-data="8538"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rMdBzZhoFJJAePuz/VBeQ" User-Agent: KNode/4.4.11 Cancel-Lock: sha1:8mS4ZuL4gmJq+zfISPDKNEX6vcY= Xref: csiph.com comp.lang.python:80392 Veek M wrote: > new_col = self.b[row].index('def') > self.w.cursor = row, new_col > new_col = self.b[row].rindex('def') > self.w.cursor = row, new_col There's also the different methods index vs rindex. Does this sort of thing justify two functions and associated infrastructure (it's for vim so 2 x 3 mode lines in my .vimrc)