def _assert_index(cond, msg):
    if not cond:
        raise IndexError(msg)