def make_rowcol(string):
 rowlens = [(len(x) + 1) for x in string.split('\n')]
 rowpos = []
 acc = 0
 for i in rowlens:
  acc += i
  rowpos.append(acc)
 def rowcol(pos):
  last = 0
  for (i, k) in enumerate(rowpos, 0):
   if (pos < k):
    return (i, (pos - last))
   last = k
  return ((-1), (-1))
 return rowcol

def make_rowcol ( string ) : rowlens = [ ( len ( x ) + 1 ) for x in string . split ( '\n' ) ] rowpos = [ ] acc = 0 for i in rowlens : acc += i rowpos . append ( acc ) def rowcol ( pos ) : last = 0 for ( i , k ) in enumerate ( rowpos , 0 ) : if ( pos < k ) : return ( i , ( pos - last ) ) last = k return ( ( - 1 ) , ( - 1 ) ) return rowcol
creates a rowcol function similar to the rowcol function of a view arguments: string -- the string on which the rowcol function should hold returns: a function similar to the rowcol function of a sublime text view .