##// END OF EJS Templates
Update a couple of iteration idioms....
Matthias Bussonnier -
Show More
@@ -189,11 +189,11 b' def findsource(object):'
189 # use the one with the least indentation, which is the one
189 # use the one with the least indentation, which is the one
190 # that's most probably not inside a function definition.
190 # that's most probably not inside a function definition.
191 candidates = []
191 candidates = []
192 for i in range(len(lines)):
192 for i, line in enumerate(lines):
193 match = pat.match(lines[i])
193 match = pat.match(line)
194 if match:
194 if match:
195 # if it's at toplevel, it's already the best one
195 # if it's at toplevel, it's already the best one
196 if lines[i][0] == 'c':
196 if line[0] == 'c':
197 return lines, i
197 return lines, i
198 # else add whitespace to candidate list
198 # else add whitespace to candidate list
199 candidates.append((match.group(1), i))
199 candidates.append((match.group(1), i))
@@ -358,7 +358,7 b' def _fixed_getinnerframes(etb, context=1, tb_offset=0):'
358
358
359 aux = traceback.extract_tb(etb)
359 aux = traceback.extract_tb(etb)
360 assert len(records) == len(aux)
360 assert len(records) == len(aux)
361 for i, (file, lnum, _, _) in zip(range(len(records)), aux):
361 for i, (file, lnum, _, _) in enumerate(aux):
362 maybeStart = lnum - 1 - context // 2
362 maybeStart = lnum - 1 - context // 2
363 start = max(maybeStart, 0)
363 start = max(maybeStart, 0)
364 end = start + context
364 end = start + context
@@ -84,7 +84,7 b' def token_at_cursor(cell, cursor_pos=0):'
84 if end_line + 1 not in offsets:
84 if end_line + 1 not in offsets:
85 # keep track of offsets for each line
85 # keep track of offsets for each line
86 lines = tok.line.splitlines(True)
86 lines = tok.line.splitlines(True)
87 for lineno, line in zip(range(start_line + 1, end_line + 2), lines):
87 for lineno, line in enumerate(lines, start_line + 1):
88 if lineno not in offsets:
88 if lineno not in offsets:
89 offsets[lineno] = offsets[lineno-1] + len(line)
89 offsets[lineno] = offsets[lineno-1] + len(line)
90
90
General Comments 0
You need to be logged in to leave comments. Login now