code: def linecol_to_pos(text, line, col):
      
      nth_newline_offset = 0
      for i in range(line - 1):
          new_offset = text.find("\n", nth_newline_offset)
          if new_offset < 0:
              raise ValueError("Text does not have {0} lines."
                               .format(line))
          nth_newline_offset = new_offset + 1
      offset = nth_newline_offset + col
      if offset > len(text):
          raise ValueError("Line {0} column {1} is not within the text"
                           .format(line, col))
      return offset
docs: Return the offset of this line and column in text.
  
      Lines are one-based, columns zero-based.
  
      This is how Jedi wants it. Don't ask me why.