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

2014-11-09 Thread Veek M
Ned Batchelder wrote: On 11/7/14 9:52 AM, Veek M wrote: and you want to end up on the def token, not the def in yep, bumped into this :) thanks! -- https://mail.python.org/mailman/listinfo/python-list

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

2014-11-08 Thread Ned Batchelder
On 11/7/14 9:52 AM, Veek M wrote: 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

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

2014-11-07 Thread Veek M
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:

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

2014-11-07 Thread Joel Goldstick
On Fri, Nov 7, 2014 at 5:16 AM, Veek M vek.m1...@gmail.com wrote: 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,

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

2014-11-07 Thread Denis McMahon
On Fri, 07 Nov 2014 21:22:22 +0630, Veek M wrote: 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

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

2014-11-07 Thread Chris Angelico
On Fri, Nov 7, 2014 at 9:16 PM, Veek M vek.m1...@gmail.com wrote: 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,

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

2014-11-07 Thread Veek M
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

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

2014-11-07 Thread Denis McMahon
On Fri, 07 Nov 2014 16:46:19 +0630, Veek M wrote: (1) Pass a true or false parameter to the function as the direction of search toggle. (2) replace the relevant assignments with something like: variable = something if condition else something else (3) Figuring out the while loop control is a