def find_column ( token ) : i = token . lexpos input = token . lexer . lexdata while i > 0 : if input [ i - 1 ] == '\n' : break i -= 1 column = token . lexpos - i + 1 return column
tokenizing a column python
Compute column : input is the input text string token is a token instance
def find_column(token):
    """ Compute column:
            input is the input text string
            token is a token instance
    """
    i = token.lexpos
    input = token.lexer.lexdata

    while i > 0:
        if input[i - 1] == '\n':
            break
        i -= 1

    column = token.lexpos - i + 1

    return column