import itertools


def _col_name(index):
    """
    Converts a column index to a column name.

    >>> _col_name(0)
    'A'
    >>> _col_name(26)
    'AA'

    """
    for exp in itertools.count(1):
        limit = 26 ** exp
        if index < limit:
            return ''.join(chr(ord('A') + index // (26 ** i) % 26) for i in range(exp-1, -1, -1))
        index -= limit