def _index_to_int(idx, n):
    idx = operator.index(idx)
    if (idx < 0):
        idx += n
    if ((idx < 0) or (idx >= n)):
        raise IndexError
    return idx
def _index_to_int(idx, n):
    idx = operator.index(idx)
    if (idx < 0):
        idx += n
    if ((idx < 0) or (idx >= n)):
        raise IndexError
    return idx