Return currnet column in line

def p_current_col(self):
        "Return currnet column in line"
        prefix = self.input[:self.pos]
        nlidx = prefix.rfind('\n')
        if nlidx == -1:
            return self.pos
        return self.pos - nlidx