def find_position(string, index, last_index, last_pos):
    """
    Given a string and index, return (line, column)
    """
    lines = string.count('\n', last_index, index)
    if lines > 0:
        column = index - string.rfind('\n', last_index, index)
    else:
        column = last_pos[1] + (index - last_index)
    return (last_pos[0] + lines, column)
dataset/ETHPy150Open mne-tools/mne-python/mne/externals/tempita/__init__.py/find_position/original